[ Index ] |
|
Code source de phpMyAdmin 2.10.3 |
1 <?php 2 /* $Id: docsql.php 9611 2006-10-26 11:06:20Z nijel $ */ 3 // vim: expandtab sw=4 ts=4 sts=4 ft=php: 4 5 /* DocSQL import plugin for phpMyAdmin */ 6 7 /* We need relations enabled and we work only on database */ 8 if ($plugin_param == 'database' && $GLOBALS['num_tables'] > 0 && $GLOBALS['cfgRelation']['relwork'] && $GLOBALS['cfgRelation']['commwork']) { 9 if (isset($plugin_list)) { 10 $plugin_list['docsql'] = array( // set name of your plugin 11 'text' => 'strDocSQL', // text to be displayed as choice 12 'extension' => '', // extension this plugin can handle 13 'options' => array( // array of options for your plugin (optional) 14 array('type' => 'text', 'name' => 'table', 'text' => 'strTableName'), 15 ), 16 'options_text' => 'strDocSQLOptions', // text to describe plugin options (must be set if options are used) 17 ); 18 } else { 19 /* We do not define function when plugin is just queried for information above */ 20 $tab = $_POST['docsql_table']; 21 $buffer = ''; 22 /* Read whole buffer, we except it is small enough */ 23 while (!$finished && !$error && !$timeout_passed) { 24 $data = PMA_importGetNextChunk(); 25 if ($data === FALSE) { 26 // subtract data we didn't handle yet and stop processing 27 break; 28 } elseif ($data === TRUE) { 29 // nothing to read 30 break; 31 } else { 32 // Append new data to buffer 33 $buffer .= $data; 34 } 35 } // End of import loop 36 /* Process the data */ 37 if ($data === TRUE && !$error && !$timeout_passed) { 38 $buffer = str_replace("\r\n", "\n", $buffer); 39 $buffer = str_replace("\r", "\n", $buffer); 40 $lines = explode("\n", $buffer); 41 foreach ($lines AS $lkey => $line) { 42 //echo '<p>' . $line . '</p>'; 43 $inf = explode('|', $line); 44 if (!empty($inf[1]) && strlen(trim($inf[1])) > 0) { 45 $qry = ' 46 INSERT INTO 47 ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['column_info']) . ' 48 ( db_name, table_name, column_name, ' . PMA_backquote('comment') . ' ) 49 VALUES ( 50 \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\', 51 \'' . PMA_sqlAddslashes(trim($tab)) . '\', 52 \'' . PMA_sqlAddslashes(trim($inf[0])) . '\', 53 \'' . PMA_sqlAddslashes(trim($inf[1])) . '\')'; 54 PMA_importRunQuery($qry, $qry . '-- ' . htmlspecialchars($tab) . '.' . htmlspecialchars($inf[0]), true); 55 } // end inf[1] exists 56 if (!empty($inf[2]) && strlen(trim($inf[2])) > 0) { 57 $for = explode('->', $inf[2]); 58 $qry = ' 59 INSERT INTO 60 ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['relation']) . ' 61 ( master_db, master_table, master_field, foreign_db, foreign_table, foreign_field) 62 VALUES ( 63 \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\', 64 \'' . PMA_sqlAddslashes(trim($tab)) . '\', 65 \'' . PMA_sqlAddslashes(trim($inf[0])) . '\', 66 \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\', 67 \'' . PMA_sqlAddslashes(trim($for[0])) . '\', 68 \'' . PMA_sqlAddslashes(trim($for[1])) . '\')'; 69 PMA_importRunQuery($qry, $qry . '-- ' . htmlspecialchars($tab) . '.' . htmlspecialchars($inf[0]) . '(' . htmlspecialchars($inf[2]) . ')', true); 70 } // end inf[2] exists 71 } // End lines loop 72 } // End import 73 // Commit any possible data in buffers 74 PMA_importRunQuery(); 75 } 76 } 77 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 15:18:20 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |