diff --git a/ChangeLog b/ChangeLog index 554c848bb..4ea1a121c 100755 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ $Source$ 2004-01-20 Marc Delisle * all concerned scripts: PMA_DBI_num_rows() * all concerned scripts: PMA_DBI_free_result() + * all concerned scripts: PMA_DBI_insert_id() 2004-01-19 Marc Delisle * libraries/common.lib.php, libraries/dbi/mysql.dbi.lib.php: diff --git a/libraries/dbi/mysql.dbi.lib.php b/libraries/dbi/mysql.dbi.lib.php index ca26e17e1..fb3ee8c46 100644 --- a/libraries/dbi/mysql.dbi.lib.php +++ b/libraries/dbi/mysql.dbi.lib.php @@ -171,7 +171,11 @@ function PMA_DBI_close($link = '') { function PMA_DBI_get_dblist($link = '') { if (empty($link)) { - $link = $GLOBALS['userlink']; + if (isset($GLOBALS['userlink'])) { + $link = $GLOBALS['userlink']; + } else { + return FALSE; + } } $res = PMA_DBI_try_query('SHOW DATABASES;', $link); $dbs_array = array(); @@ -198,4 +202,15 @@ function PMA_DBI_num_rows($result) { return mysql_num_rows($result); } +function PMA_DBI_insert_id($link) { + if (empty($link)) { + if (isset($GLOBALS['userlink'])) { + $link = $GLOBALS['userlink']; + } else { + return FALSE; + } + } + return mysql_insert_id($link); +} + ?> diff --git a/pdf_pages.php b/pdf_pages.php index e7ff08d54..d00e854b0 100644 --- a/pdf_pages.php +++ b/pdf_pages.php @@ -81,7 +81,7 @@ if ($cfgRelation['pdfwork']) { if (isset($autolayout)) { // save the page number - $pdf_page_number = mysql_insert_id((isset($dbh)?$dbh:'')); + $pdf_page_number = PMA_DBI_insert_id((isset($dbh)?$dbh:'')); // get the tables that have relations, by descending // number of links diff --git a/sql.php b/sql.php index 70ca128b6..56da97084 100644 --- a/sql.php +++ b/sql.php @@ -526,7 +526,7 @@ else { $message = $strDeletedRows . ' ' . $num_rows; } else if ($is_insert) { $message = $strInsertedRows . ' ' . $num_rows; - $insert_id = mysql_insert_id(); + $insert_id = PMA_DBI_insert_id(); if ($insert_id != 0) { $message .= '
'.$strInsertedRowId . ' ' . $insert_id; } diff --git a/tbl_move_copy.php b/tbl_move_copy.php index f879526fc..b71ced829 100644 --- a/tbl_move_copy.php +++ b/tbl_move_copy.php @@ -92,7 +92,7 @@ global $cfgRelation; . ' (\'' . implode('\', \'', $value_parts) . '\', \'' . implode('\', \'', $new_value_parts) . '\')'; $new_table_rs = PMA_query_as_cu($new_table_query); - $last_id = (@function_exists('mysql_insert_id') ? @mysql_insert_id() : -1); + $last_id = (@function_exists('mysql_insert_id') ? @PMA_DBI_insert_id() : -1); } // end while return $last_id; diff --git a/tbl_replace.php b/tbl_replace.php index 344401f39..885ece1ba 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -219,7 +219,7 @@ foreach($query AS $query_index => $single_query) { $total_affected_rows += @mysql_affected_rows(); } - $insert_id = mysql_insert_id(); + $insert_id = PMA_DBI_insert_id(); if ($insert_id != 0) { $last_message .= '
'.$strInsertedRowId . ' ' . $insert_id; }