note 106044 deleted from function.mysql-info by danbrown
| From: | danbrown@php.net | Date: | Wed, 05 Oct 2011 16:02:08 +0000 |
| Subject: | note 106044 deleted from function.mysql-info by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183646@lists.php.net to get a copy of this message | ||
Note Submitter: l.corrochano at free.fr
----
Hi, the Eric's function was nice for some test so i updated it to get no more DEPRECATED
warning concerning ereg.
Surely not perfect but functional.
function get_mysql_info($linkid = null){
$linkid? $strInfo = mysql_info($linkid) : $strInfo = mysql_info();
$return = array();
preg_match("/(Records): ([0-9]*)/", $strInfo, $records);
preg_match("/(Duplicates): ([0-9]*)/", $strInfo, $dupes);
preg_match("/(Warnings): ([0-9]*)/", $strInfo, $warnings);
preg_match("/(Deleted): ([0-9]*)/", $strInfo, $deleted);
preg_match("/(Skipped): ([0-9]*)/", $strInfo, $skipped);
preg_match("/(Rows matched): ([0-9]*)/", $strInfo, $rows_matched);
preg_match("/(Changed): ([0-9]*)/", $strInfo, $changed);
$return['records'] = isset($records['2']) ? $records['2'] : NULL;
$return['duplicates'] = isset($dupes['2']) ? $dupes['2'] : NULL;
$return['warnings'] = isset($warnings['2']) ? $warnings['2'] :
NULL;
$return['deleted'] = isset($deleted['2']) ? $deleted['2'] : NULL;
$return['skipped'] = isset($skipped['2']) ? $skipped['2'] : NULL;
$return['rows_matched'] = isset($rows_matched['2']) ?
$rows_matched['2'] : NULL;
$return['changed'] = isset($changed['2']) ? $changed['2'] : NULL;
return $return;
}