// add tables that plugins want to backup to the list\r
// catch all output generated by plugins\r
ob_start();\r
- $res = sql_query('SELECT pfile FROM ' . sql_table('plugin'));\r
- while ( $plugName = sql_fetch_object($res) )\r
+ $query = sprintf('SELECT pfile FROM %s', sql_table('plugin'));\r
+ $res = DB::getResult($query);\r
+ foreach ( $res as $row )\r
{\r
- $plug =& $manager->getPlugin($plugName->pfile);\r
+ $plug =& $manager->getPlugin($row['pfile']);\r
if ( $plug )\r
{\r
$tables = array_merge($tables, (array) $plug->getTableList());\r
static private function dump_structure($tablename)\r
{\r
// add command to drop table on restore\r
- echo "DROP TABLE IF EXISTS `$tablename`;\n\n";\r
- $result = sql_query("SHOW CREATE TABLE $tablename");\r
- $create = sql_fetch_assoc($result);\r
- echo $create['Create Table'];\r
+ echo "DROP TABLE IF EXISTS {$tablename};\n\n";\r
+ $result = DB::getRow("SHOW CREATE TABLE {$tablename}");\r
+ echo $result['Create Table'];\r
echo ";\n\n";\r
return;\r
}\r
$fields = array();\r
for ( $j = 0; $j < $num_fields; $j++ )\r
{\r
- $fields[] = sql_field_name($result, $j);\r
+ $col = $result->getColumnMeta($j);\r
+ $fields[] = $col['name'];\r
}\r
\r
return '(' . implode(', ', $fields) . ')';\r
/*\r
* Grab the data from the table.\r
*/\r
- $result = sql_query("SELECT * FROM $tablename");\r
+ $result = DB::getResult("SELECT * FROM $tablename");\r
\r
- if ( sql_num_rows($result) > 0 )\r
+ if ( $result->rowCount() > 0 )\r
{\r
echo "\n";\r
echo "/*\n";\r
echo " */\n";\r
}\r
\r
- $num_fields = sql_num_fields($result);\r
+ $num_fields = $result->columnCount();\r
\r
/*\r
* Compose fieldname list\r
/*\r
* Loop through the resulting rows and build the sql statement.\r
*/\r
- while ( $row = sql_fetch_array($result) )\r
+ foreach ( $result as $row )\r
{\r
// Start building the SQL statement.\r
- echo "INSERT INTO ".$tablename." $tablename_list VALUES(";\r
+ echo 'INSERT INTO ' . $tablename . ' ' . $tablename_list . ' VALUES(';\r
\r
// Loop through the rows and fill in data for each column\r
for ( $j = 0; $j < $num_fields; $j++ )\r
elseif ( $row[$j] != '' )\r
{\r
// data\r
- echo " '" . sql_real_escape_string($row[$j]) . "'";\r
+ echo ' ' . DB::quoteValue($row[$j]);\r
}\r
else\r
{\r
// only add comma when not last column\r
if ( $j != ($num_fields - 1) )\r
{\r
- echo ",";\r
+ echo ',';\r
}\r
}\r
echo ");\n";\r
/* execute sql statements */\r
foreach ( $queries as $query )\r
{\r
- if ( !sql_query($query) )\r
+ if ( !DB::execute($query) )\r
{\r
- debug('SQL Error: ' . sql_error());\r
+ $error = DB::getError();\r
+ debug('SQL Error: ' . $error[2]);\r
break;\r
}\r
continue;\r