本文整理汇总了PHP中mysql_info函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_info函数的具体用法?PHP mysql_info怎么用?PHP mysql_info使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query
function query($sql, $type = '')
{
if (defined('SHOW_SQL')) {
global $_SGLOBAL;
$sqlstarttime = $sqlendttime = 0;
$mtime = explode(' ', microtime());
$sqlstarttime = number_format($mtime[1] + $mtime[0] - $_SGLOBAL['supe_starttime'], 6) * 1000;
echo $sql . '<br>';
}
$func = $type == 'UNBUFFERED' && @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query';
if (!($query = $func($sql, $this->link)) && $type != 'SILENT') {
$this->halt('MySQL Query Error', $sql);
}
if (defined('SHOW_SQL')) {
$mtime = explode(' ', microtime());
$sqlendttime = number_format($mtime[1] + $mtime[0] - $_SGLOBAL['supe_starttime'], 6) * 1000;
$sqltime = round($sqlendttime - $sqlstarttime, 3);
echo $sqltime . '<br>';
$explain = array();
$info = mysql_info();
if ($query && preg_match("/^(select )/i", $sql)) {
$explain = mysql_fetch_assoc(mysql_query('EXPLAIN ' . $sql, $this->link));
}
$_SGLOBAL['debug_query'][] = array('sql' => $sql, 'time' => $sqltime, 'info' => $info, 'explain' => $explain);
}
$this->querynum++;
return $query;
}
示例2: query
function query($sql, $type = '')
{
if (D_BUG) {
$mtime = explode(' ', microtime());
$sqlstarttime = $mtime[1] + $mtime[0];
}
$func = $type == 'UNBUFFERED' && @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query';
if (!($query = $func($sql, $this->link_identifier)) && $type != 'SILENT') {
$this->halt('MySQL Query Error', $sql);
}
if (D_BUG) {
global $_SGLOBAL;
if (empty($_SGLOBAL['debug_query'])) {
$_SGLOBAL['debug_query'] = array();
}
$mtime = explode(' ', microtime());
$sqltime = number_format($mtime[1] + $mtime[0] - $sqlstarttime, 6) * 1000;
$explain = array();
$info = mysql_info();
if (strtolower(substr($sql, 0, 7)) == 'select ') {
$explain = mysql_fetch_assoc(mysql_query('EXPLAIN ' . $sql, $this->link_identifier));
}
$_SGLOBAL['debug_query'][] = array('sql' => $sql, 'time' => $sqltime, 'info' => $info, 'explain' => $explain);
}
$this->querynum++;
return $query;
}
示例3: dbmanager_query
function dbmanager_query($sql, &$error)
{
global $config;
$retval = array();
if ($sql == '') {
return false;
}
$sql = html_entity_decode($sql, ENT_QUOTES);
$result = mysql_query($sql);
if ($result === false) {
$error = mysql_error();
return false;
}
if ($result === true) {
if ($rettype == "insert_id") {
return mysql_insert_id();
} elseif ($rettype == "info") {
return mysql_info();
}
return mysql_affected_rows();
}
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
array_push($retval, $row);
}
mysql_free_result($result);
if (!empty($retval)) {
return $retval;
}
//Return false, check with === or !==
return false;
}
示例4: show_db_results
function show_db_results($result)
{
if ($result || mysql_errno == 0) {
echo 'Query Info: ' . mysql_info();
echo '<table class="eb_table">';
if (mysql_num_rows($result) > 0) {
$fields_num = mysql_num_fields($result);
echo "<tr>";
// printing table headers
for ($i = 0; $i < $fields_num; $i++) {
$field = mysql_fetch_field($result);
echo "<th class='eb_th1'>{$field->table}<br/>{$field->name}</td>";
}
echo "</tr>";
// printing table rows
while ($row = mysql_fetch_row($result)) {
echo "<tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach ($row as $cell) {
echo "<td class='eb_td'>{$cell}</td>";
}
echo "</tr>";
}
} else {
echo "<tr><td colspan='" . ($i + 1) . "'>No Results found!</td></tr>";
}
echo "</table>";
} else {
echo "Error in running query :" . mysql_error();
}
}
示例5: mysql_modified_rows
function mysql_modified_rows($conn)
{
$info_str = mysql_info($conn);
$a_rows = mysql_affected_rows();
ereg("Rows matched: ([0-9]*)", $info_str, $r_matched);
return $a_rows < 1 ? $r_matched[1] ? $r_matched[1] : 0 : $a_rows;
}
示例6: GetModifiedRows
function GetModifiedRows()
{
// Code lifted from http://ca3.php.net/manual/en/function.mysql-info.php#65118
$infoString = mysql_info();
$affectedRows = mysql_affected_rows();
ereg("Rows matched: ([0-9]*)", $infoString, $rowsMatched);
return $affectedRows < 1 ? $rowsMatched[1] ? $rowsMatched[1] : 0 : $affectedRows;
}
示例7: update_table
function update_table($how, $table_name, $column_name, $allow_nonexistent_table = FALSE)
{
global $src_round_id, $dst_round_id;
global $already_appears;
$sql = array();
if ($how == WHOLE_COL) {
// When a round-id appears in the column,
// it's the only thing in the column.
$sql['SELECT'] = "\n SELECT COUNT(*)\n FROM {$table_name}\n WHERE {$column_name} = '{$dst_round_id}'\n ";
$sql['UPDATE'] = "\n UPDATE {$table_name}\n SET {$column_name} = '{$dst_round_id}'\n WHERE {$column_name} = '{$src_round_id}'\n ";
} else {
if ($how == PART_OF_COL) {
// When a round-id appears in the column,
// there may be other stuff in the column.
// Note that 'BINARY' forces a case-sensitive search.
$sql['SELECT'] = "\n SELECT COUNT(*)\n FROM {$table_name}\n WHERE INSTR({$column_name}, BINARY '{$dst_round_id}')\n ";
$sql['UPDATE'] = "\n UPDATE {$table_name}\n SET {$column_name} = REPLACE({$column_name},'{$src_round_id}','{$dst_round_id}')\n WHERE INSTR({$column_name}, BINARY '{$src_round_id}')\n AND NOT INSTR({$column_name}, BINARY '{$src_round_id}_mentor')\n ";
// The '_mentor' thing is a kludge:
// We don't want P2_mentor changed to P3_mentor
// in usersettings.setting or access_log.activity
} else {
die("bad how: '{$how}'");
}
}
// First, look to see if the dst id already appears in any of the tables.
// If so, it either means you already ran this script on that table
// (in which case you don't need to do the update again)
// or else the dst id appears of its own accord,
// (in which case it might be dangerous to do the update).
foreach (array('SELECT', 'UPDATE') as $pass) {
$res = mysql_query($sql[$pass]);
if (!$res) {
if ($allow_nonexistent_table && mysql_errno() == 1146) {
// skip it
return;
} else {
echo "\n";
echo $table_name, "\n";
echo mysql_error(), "\n";
exit;
}
} else {
if ($pass == 'SELECT') {
list($count) = mysql_fetch_row($res);
if ($count > 0) {
echo str_pad($table_name, 23), "{$dst_round_id} already appears!!!\n";
$already_appears[] = "{$table_name}.{$column_name}";
// skip UPDATE pass
return;
}
} else {
echo str_pad($table_name, 23), mysql_info(), "\n";
}
}
}
}
示例8: query
/** Utfør spørring */
public function query($query, $critical = true, $debug = false)
{
// hent data
$result = parent::query($query, $critical, $debug);
$info = mysql_info($this->link);
// tid siden forrige spørring
if ($this->lastquery) {
$time = $this->time_last_begin - $this->lastquery;
} else {
$time = 0;
}
// lagre debug
$this->queries_text[] = array("script_time____" => (microtime(true) - SCRIPT_START) * 1000, "time_last_query" => round($time, 6) * 1000, "query_time_____" => round($this->time_last, 6) * 1000, "query_info_____" => $info, "query__________" => $query);
$this->lastquery = microtime(true);
// send svaret tilbake
return $result;
}
示例9: mysql_insert_array
function mysql_insert_array($table, $data, $exclude = array())
{
$fields = $values = array();
if (!is_array($exclude)) {
$exclude = array($exclude);
}
foreach (array_keys($data) as $key) {
if (!in_array($key, $exclude)) {
$fields[] = "`{$key}`";
$values[] = "'" . mysql_real_escape_string($data[$key]) . "'";
}
}
$fields = implode(",", $fields);
$values = implode(",", $values);
if (mysql_query("INSERT INTO `{$table}` ({$fields}) VALUES ({$values})")) {
return array("mysql_error" => false, "mysql_insert_id" => mysql_insert_id(), "mysql_affected_rows" => mysql_affected_rows(), "mysql_info" => mysql_info());
} else {
return array("mysql_error" => mysql_error());
}
}
示例10: GetMySQL_ResultStats
function GetMySQL_ResultStats($linkid = null)
{
$linkid ? $strInfo = mysql_info($linkid) : ($strInfo = mysql_info());
$return = array();
ereg("Records: ([0-9]*)", $strInfo, $records);
ereg("Duplicates: ([0-9]*)", $strInfo, $dupes);
ereg("Warnings: ([0-9]*)", $strInfo, $warnings);
ereg("Deleted: ([0-9]*)", $strInfo, $deleted);
ereg("Skipped: ([0-9]*)", $strInfo, $skipped);
ereg("Rows matched: ([0-9]*)", $strInfo, $rows_matched);
ereg("Changed: ([0-9]*)", $strInfo, $changed);
$return['records'] = $records[1];
$return['duplicates'] = $dupes[1];
$return['warnings'] = $warnings[1];
$return['deleted'] = $deleted[1];
$return['skipped'] = $skipped[1];
$return['rows_matched'] = $rows_matched[1];
$return['changed'] = $changed[1];
return $return;
}
示例11: get_mysql_info
function get_mysql_info()
{
$strInfo = mysql_info($this->_conn);
$return = array();
ereg("Records: ([0-9]*)", $strInfo, $records);
ereg("Duplicates: ([0-9]*)", $strInfo, $dupes);
ereg("Warnings: ([0-9]*)", $strInfo, $warnings);
ereg("Deleted: ([0-9]*)", $strInfo, $deleted);
ereg("Skipped: ([0-9]*)", $strInfo, $skipped);
ereg("Rows matched: ([0-9]*)", $strInfo, $rows_matched);
ereg("Changed: ([0-9]*)", $strInfo, $changed);
$return['records'] = $records[1];
$return['duplicates'] = $dupes[1];
$return['warnings'] = $warnings[1];
$return['deleted'] = $deleted[1];
$return['skipped'] = $skipped[1];
$return['rows_matched'] = $rows_matched[1];
$return['changed'] = $changed[1];
return $return;
}
示例12: log_in
/**
* Авторизация на форуме
* @param string $login
* @param string $password
* @return boolean
*/
public function log_in($login, $password)
{
Yii::app()->request->enableCookieValidation = false;
//
$row = $this->FDB->createCommand("SELECT user_id, user_active, username, user_password, user_level, user_login_tries, user_last_login_try FROM {$this->tbl_prefix}users WHERE username = '" . $login . "'")->queryRow();
if (isset($row)) {
if (md5($password) == $row['user_password'] and $row['user_active']) {
$user_ip = $this->encode_ip($_SERVER['REMOTE_ADDR']);
$cookiename = $this->board_config['cookie_name'];
$cookiepath = $this->board_config['cookie_path'];
$cookiedomain = $this->board_config['cookie_domain'];
$cookiesecure = $this->board_config['cookie_secure'];
$user_id = $row['user_id'];
$current_time = time();
$auto_login_key = $this->dss_rand() . $this->dss_rand();
$this->FDB->createCommand("UPDATE {$this->tbl_prefix}sessions_keys SET last_ip = '{$user_ip}', key_id = '" . md5($auto_login_key) . "', last_login = {$current_time} WHERE user_id='" . $user_id . "'")->execute();
$e = @mysql_info();
//print_r($e);
// die;
preg_match("/^\\D+(\\d+)/", $e, $matches);
if ($matches[1] == 0) {
$this->FDB->createCommand("INSERT INTO {$this->tbl_prefix}sessions_keys (key_id, user_id, last_ip, last_login) VALUES ('" . md5($auto_login_key) . "', '{$user_id}', '{$user_ip}', '{$current_time}')")->execute();
}
$result = $this->FDB->createCommand("UPDATE {$this->tbl_prefix}sessions SET session_user_id = '" . $user_id . "', session_start = '" . $current_time . "', session_time = '" . $current_time . "', session_page = '" . $page_id . "', session_logged_in = '" . $login . "', session_admin = '" . $admin . "' WHERE session_user_id = '" . $user_id . "' AND session_ip = '{$user_ip}'")->execute();
if (!$result) {
$session_id = md5($this->dss_rand());
$this->FDB->createCommand("INSERT INTO {$this->tbl_prefix}sessions (session_id, session_user_id, session_start, session_time, session_ip, session_page, session_logged_in, session_admin) VALUES ('{$session_id}', '{$user_id}', '{$current_time}', '{$current_time}', '{$user_ip}', '0', '1', '0')")->execute();
}
$sessiondata['autologinid'] = $auto_login_key;
$sessiondata['userid'] = $user_id;
setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);
return true;
} else {
return false;
}
} else {
return false;
}
}
示例13: while
}
break;
case 5:
$ted = '';
$_POST2 = $_POST;
# X.Z. zachem, xernya kakaeto :)
while (list($key1, $val1) = each($_POST2)) {
if (preg_match('/ed_key:(.+)/', $key1, $m)) {
$ted .= "`" . $m[1] . "`= '" . addslashes($val1) . "', ";
}
}
$ted = substr($ted, 0, -2);
$query = (isset($_POST['insert']) ? "INSERT" : "UPDATE") . " `" . $_POST['table_sel'] . "` SET {$ted} " . (isset($_POST['insert']) ? '' : "WHERE " . urldecode($_POST['edit']) . " LIMIT 1 ");
echo "<div style='background-color:white;'>" . htmlspecialchars($query, ENT_QUOTES) . "</div><br>";
$result = mysql_query($query, $connect) or print "<div style='background-color:red;'>" . mysql_error($connect) . "</div>";
echo "<div style='background-color:green;'>" . mysql_info($connect) . "</div>";
break;
}
}
echo "</td></tr></table></td></tr></table><input type=hidden name=sql>\n";
} else {
echo $text;
}
echo "</form></body>";
exit;
}
echo "<html><body bgcolor=white><center><table bgcolor=orange height=10 border=1><tr><td><nobr>" . font('blue', @php_uname()) . "</nobr></td></tr></table><table bgcolor=orange height=10 border=1><tr><nobr><td>" . font('blue', 'PHP:' . @phpversion()) . "</nobr></td><td><nobr>" . font('blue', date('H:i:s l d F Y')) . "</nobr></td><td><nobr>" . font('blue', getenv('SERVER_ADDR')) . "</nobr></td><td><nobr>" . font('blue', getenv('REMOTE_ADDR')) . "</nobr></td></tr></table><br></center>\n";
if (!test_file('/etc/shadow')) {
echo font('red', b('shadow readable<br>'));
}
if (!test_file('/etc/shadow-')) {
示例14: updateDocument
/**
* updateDocument
* @version 1.2 (2012-10-26)
*
* @desc Update a document.
*
* @note $id и/или $where должны быть переданы
*
* @param $id {integer; array} - Document id to update. @required
* @param $update {array} - Array of document fields or TVs to update. Key — name, value — value. @required
* @param $where {string} - SQL WHERE string. Default: ''.
*
* @return {boolean} - true — если всё хорошо, или false — если такого документа нет, или ещё что-то пошло не так.
*/
public static function updateDocument($id = 0, $update = array(), $where = '')
{
global $modx;
if ($id == 0 && trim($where) == '') {
return false;
}
$where_sql = '';
if (is_array($id) && count($id)) {
//Обрабатываем массив id
$where_sql .= "`id` IN ('" . implode("','", $id) . "')";
} else {
if (is_numeric($id) && $id != 0) {
//Обрабатываем числовой id
$where_sql .= "`id`='{$id}'";
}
}
//Добавляем дополнительное условие
if ($where != '') {
$where_sql .= ($where_sql != '' ? ' AND ' : '') . $where;
}
//Получаем id документов для обновления
$update_ids_res = $modx->db->select('id', self::$tables['site_content'], $where_sql);
if ($modx->db->getRecordCount($update_ids_res)) {
//Разбиваем на поля документа и TV
$update = self::explodeFieldsArr($update);
//Обновляем информацию по документу
if (count($update[0])) {
$modx->db->update($update[0], self::$tables['site_content'], $where_sql);
}
//Если есть хоть одна TV
if (count($update[1]) > 0) {
//Обновляем TV всех найденых документов
while ($doc = $modx->db->getRow($update_ids_res)) {
//Перебираем массив TV
foreach ($update[1] as $val) {
//Проверим, что id существует (а то ведь могли и именем ошибиться)
if (isset($val['id'])) {
//Пробуем обновить значение нужной TV
$modx->db->update("`value` = '{$val['val']}'", self::$tables['site_tmplvar_contentvalues'], "`tmplvarid` = {$val['id']} AND `contentid` = {$doc['id']}");
//Проверяем сколько строк нашлось при обновлении
preg_match('/Rows matched: (\\d+)/', mysql_info(), $updatedRows);
//Если ничего не обновилось (не нашлось)
if ($updatedRows[1] == 0) {
//Добавляем значение нужной TV в базу
$modx->db->insert(array('value' => $val['val'], 'tmplvarid' => $val['id'], 'contentid' => $doc['id']), self::$tables['site_tmplvar_contentvalues']);
}
}
}
}
}
return true;
} else {
//Нечего обновлять
return false;
}
}
示例15: mysql_query
$res = mysql_query($query, $conn);
$errno = mysql_errno();
$affectedrows = mysql_affected_rows($conn);
$insertid = mysql_insert_id($conn);
$numfields = mysql_num_fields($res);
$numrows = mysql_num_rows($res);
EchoResultSetHeader($errno, $affectedrows, $insertid, $numfields, $numrows);
if($errno > 0)
echo GetBlock(mysql_error());
else {
if($numfields > 0) {
EchoFieldsHeader($res, $numfields);
EchoData($res, $numfields, $numrows);
} else {
if(phpversion_int() >= 40300)
echo GetBlock(mysql_info($conn));
else
echo GetBlock("");
}
}
if($i<(count($_POST["q"])-1))
echo "\x01";
else
echo "\x00";
mysql_free_result($res);
}
}
exit();
}