本文整理汇总了PHP中MySQL::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP MySQL::fetch方法的具体用法?PHP MySQL::fetch怎么用?PHP MySQL::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySQL
的用法示例。
在下文中一共展示了MySQL::fetch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read
/**
* Given the hash of a some data, check to see whether it exists in
* `tbl_cache`. If no cached object is found, this function will return
* false, otherwise the cached object will be returned as an array.
*
* @param string $hash
* The hash of the Cached object, as defined by the user
* @param string $namespace
* The namespace allows a group of data to be retrieved at once
* @return array|boolean
* An associative array of the cached object including the creation time,
* expiry time, the hash and the data. If the object is not found, false will
* be returned.
*/
public function read($hash, $namespace = null)
{
$data = false;
// Check namespace first
if (!is_null($namespace)) {
$data = $this->Database->fetch("\n SELECT SQL_NO_CACHE *\n FROM `tbl_cache`\n WHERE `namespace` = '{$namepspace}'\n AND (`expiry` IS NULL OR UNIX_TIMESTAMP() <= `expiry`)\n ");
}
// Then check hash
if (!is_null($hash)) {
$data = $this->Database->fetchRow(0, "\n SELECT SQL_NO_CACHE *\n FROM `tbl_cache`\n WHERE `hash` = '{$hash}'\n AND (`expiry` IS NULL OR UNIX_TIMESTAMP() <= `expiry`)\n LIMIT 1\n ");
}
// If the data exists, see if it's still valid
if ($data) {
if (!($data['data'] = Cacheable::decompressData($data['data']))) {
$this->delete($hash, $namespace);
return false;
}
return $data;
}
$this->delete(null, $namespace);
return false;
}
示例2: install
function install(&$Page, $fields)
{
global $warnings;
$database_connection_error = false;
try {
$db = new MySQL();
$db->connect($fields['database']['host'], $fields['database']['username'], $fields['database']['password'], $fields['database']['port']);
$tables = $db->fetch(sprintf("SHOW TABLES FROM `%s` LIKE '%s'", mysql_escape_string($fields['database']['name']), mysql_escape_string($fields['database']['prefix']) . '%'));
} catch (DatabaseException $e) {
$database_connection_error = true;
}
## Invalid path
if (!@is_dir(rtrim($fields['docroot'], '/') . '/symphony')) {
$Page->log->pushToLog("Configuration - Bad Document Root Specified: " . $fields['docroot'], E_NOTICE, true);
define("kENVIRONMENT_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'no-symphony-dir');
}
} elseif (is_file(rtrim($fields['docroot'], '/') . '/.htaccess')) {
$Page->log->pushToLog("Configuration - Existing '.htaccess' file found: " . $fields['docroot'] . '/.htaccess', E_NOTICE, true);
define("kENVIRONMENT_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'existing-htaccess');
}
} elseif (is_dir(rtrim($fields['docroot'], '/') . '/workspace') && !is_writable(rtrim($fields['docroot'], '/') . '/workspace')) {
$Page->log->pushToLog("Configuration - Workspace folder not writable: " . $fields['docroot'] . '/workspace', E_NOTICE, true);
define("kENVIRONMENT_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'no-write-permission-workspace');
}
} elseif (!is_writable(rtrim($fields['docroot'], '/'))) {
$Page->log->pushToLog("Configuration - Root folder not writable: " . $fields['docroot'], E_NOTICE, true);
define("kENVIRONMENT_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'no-write-permission-root');
}
} elseif ($database_connection_error) {
$Page->log->pushToLog("Configuration - Could not establish database connection", E_NOTICE, true);
define("kDATABASE_CONNECTION_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'no-database-connection');
}
} elseif (version_compare($db->fetchVar('version', 0, "SELECT VERSION() AS `version`;"), '4.1', '<')) {
$version = $db->fetchVar('version', 0, "SELECT VERSION() AS `version`;");
$Page->log->pushToLog('Configuration - MySQL Version is not correct. ' . $version . ' detected.', E_NOTICE, true);
define("kDATABASE_VERSION_WARNING", true);
$warnings['database-incorrect-version'] = __('Symphony requires <code>MySQL 4.1</code> or greater to work, however version <code>%s</code> was detected. This requirement must be met before installation can proceed.', array($version));
if (!defined("ERROR")) {
define("ERROR", 'database-incorrect-version');
}
} elseif (!$db->select($fields['database']['name'])) {
$Page->log->pushToLog("Configuration - Database '" . $fields['database']['name'] . "' Not Found", E_NOTICE, true);
define("kDATABASE_CONNECTION_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'no-database-connection');
}
} elseif (is_array($tables) && !empty($tables)) {
$Page->log->pushToLog("Configuration - Database table prefix clash with '" . $fields['database']['name'] . "'", E_NOTICE, true);
define("kDATABASE_PREFIX_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'database-table-clash');
}
} elseif (trim($fields['user']['username']) == '') {
$Page->log->pushToLog("Configuration - No username entered.", E_NOTICE, true);
define("kUSER_USERNAME_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'user-no-username');
}
} elseif (trim($fields['user']['password']) == '') {
$Page->log->pushToLog("Configuration - No password entered.", E_NOTICE, true);
define("kUSER_PASSWORD_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'user-no-password');
}
} elseif ($fields['user']['password'] != $fields['user']['confirm-password']) {
$Page->log->pushToLog("Configuration - Passwords did not match.", E_NOTICE, true);
define("kUSER_PASSWORD_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'user-password-mismatch');
}
} elseif (trim($fields['user']['firstname']) == '' || trim($fields['user']['lastname']) == '') {
$Page->log->pushToLog("Configuration - Did not enter First and Last names.", E_NOTICE, true);
define("kUSER_NAME_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'user-no-name');
}
} elseif (!preg_match('/^\\w(?:\\.?[\\w%+-]+)*@\\w(?:[\\w-]*\\.)+?[a-z]{2,}$/i', $fields['user']['email'])) {
$Page->log->pushToLog("Configuration - Invalid email address supplied.", E_NOTICE, true);
define("kUSER_EMAIL_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'user-invalid-email');
}
} else {
$config = $fields;
$kDOCROOT = rtrim($config['docroot'], '/');
$database = array_map("trim", $fields['database']);
if (!isset($database['host']) || $database['host'] == "") {
$database['host'] = "localhost";
}
if (!isset($database['port']) || $database['port'] == "") {
//.........这里部分代码省略.........
示例3: MySQL
function refresh_cus_credit()
{
$mysql = new MySQL();
$sql_cusnum = 'SELECT COUNT(*) FROM customer_info;';
$result = $mysql->query($sql_cusnum);
$row = $mysql->fetch($result);
$cus_num = $row[0];
for ($num = 1; $num <= $cus_num; $num++) {
$sql_cuscredit = "select sum(order_price) from orders as o Join customer_info as c ON o.customer_id=c.customer_id where c.cus_number='{$num}';";
$result_cuscredit = $mysql->query($sql_cuscredit);
$row_cuscredit = $mysql->fetch($result_cuscredit);
$sql_refcredit = "UPDATE customer_info SET credit = '{$row_cuscredit['0']}' where cus_number='{$num}';";
$mysql->query($sql_refcredit);
}
}
示例4: install
function install(&$Page, $fields)
{
$db = new MySQL();
$db->connect($fields['database']['host'], $fields['database']['username'], $fields['database']['password'], $fields['database']['port']);
if ($db->isConnected()) {
$tables = $db->fetch("SHOW TABLES FROM `" . $fields['database']['name'] . "` LIKE '" . mysql_escape_string($fields['database']['prefix']) . "%'");
}
## Invalid path
if (!@is_dir(rtrim($fields['docroot'], '/') . '/symphony')) {
$Page->log->pushToLog("Configuration - Bad Document Root Specified: " . $fields['docroot'], SYM_LOG_NOTICE, true);
define("kENVIRONMENT_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'no-symphony-dir');
}
} elseif (is_file(rtrim($fields['docroot'], '/') . '/.htaccess')) {
$Page->log->pushToLog("Configuration - Existing '.htaccess' file found: " . $fields['docroot'] . '/.htaccess', SYM_LOG_NOTICE, true);
define("kENVIRONMENT_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'existing-htaccess');
}
} elseif (is_dir(rtrim($fields['docroot'], '/') . '/workspace') && !is_writable(rtrim($fields['docroot'], '/') . '/workspace')) {
$Page->log->pushToLog("Configuration - Workspace folder not writable: " . $fields['docroot'] . '/workspace', SYM_LOG_NOTICE, true);
define("kENVIRONMENT_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'no-write-permission-workspace');
}
} elseif (!is_writable(rtrim($fields['docroot'], '/'))) {
$Page->log->pushToLog("Configuration - Root folder not writable: " . $fields['docroot'], SYM_LOG_NOTICE, true);
define("kENVIRONMENT_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'no-write-permission-root');
}
} elseif (!$db->isConnected()) {
$Page->log->pushToLog("Configuration - Could not establish database connection", SYM_LOG_NOTICE, true);
define("kDATABASE_CONNECTION_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'no-database-connection');
}
} elseif (!$db->select($fields['database']['name'])) {
$Page->log->pushToLog("Configuration - Database '" . $fields['database']['name'] . "' Not Found", SYM_LOG_NOTICE, true);
define("kDATABASE_CONNECTION_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'no-database-connection');
}
} elseif (is_array($tables) && !empty($tables)) {
$Page->log->pushToLog("Configuration - Database table prefix clash with '" . $fields['database']['name'] . "'", SYM_LOG_NOTICE, true);
define("kDATABASE_PREFIX_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'database-table-clash');
}
} elseif (trim($fields['user']['username']) == '') {
$Page->log->pushToLog("Configuration - No username entered.", SYM_LOG_NOTICE, true);
define("kUSER_USERNAME_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'user-no-username');
}
} elseif (trim($fields['user']['password']) == '') {
$Page->log->pushToLog("Configuration - No password entered.", SYM_LOG_NOTICE, true);
define("kUSER_PASSWORD_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'user-no-password');
}
} elseif ($fields['user']['password'] != $fields['user']['confirm-password']) {
$Page->log->pushToLog("Configuration - Passwords did not match.", SYM_LOG_NOTICE, true);
define("kUSER_PASSWORD_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'user-password-mismatch');
}
} elseif (trim($fields['user']['firstname']) == '' || trim($fields['user']['lastname']) == '') {
$Page->log->pushToLog("Configuration - Did not enter First and Last names.", SYM_LOG_NOTICE, true);
define("kUSER_NAME_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'user-no-name');
}
} elseif (!ereg('^[a-zA-Z0-9_\\.\\-]+@[a-zA-Z0-9\\-]+\\.[a-zA-Z0-9\\-\\.]+$', $fields['user']['email'])) {
$Page->log->pushToLog("Configuration - Invalid email address supplied.", SYM_LOG_NOTICE, true);
define("kUSER_EMAIL_WARNING", true);
if (!defined("ERROR")) {
define("ERROR", 'user-invalid-email');
}
} else {
$config = $fields;
$kDOCROOT = rtrim($config['docroot'], '/');
$database = array_map("trim", $fields['database']);
if (!isset($database['host']) || $database['host'] == "") {
$database['host'] = "localhost";
}
if (!isset($database['port']) || $database['port'] == "") {
$database['port'] = "3306";
}
if (!isset($database['prefix']) || $database['prefix'] == "") {
$database['prefix'] = "sym_";
}
$install_log = $Page->log;
$start = time();
$install_log->writeToLog(CRLF . '============================================', true);
$install_log->writeToLog('INSTALLATION PROCESS STARTED (' . date("d.m.y H:i:s") . ')', true);
$install_log->writeToLog('============================================', true);
$db = new MySQL();
$install_log->pushToLog("MYSQL: Establishing Connection...", SYM_LOG_NOTICE, true, false);
//.........这里部分代码省略.........
示例5: MySQL
<link type="text/css" rel="stylesheet" href="css/kube.css"/>
</head>
<body><br/>
<row centered>
<column cols="6">
<?php
require_once "database.php";
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);
session_start();
$mysql = new MySQL();
$sql_foodinfo = "select s.food_id,s.cata_name as food_name,s.price,p.cata_name from food_catalogue as s join food_catalogue as p where p.food_id = s.catalog_id and s.food_id != s.catalog_id;";
$result = $mysql->query($sql_foodinfo);
$food_cata_info = array();
echo "<form action ='submit.php' method = 'post'>";
echo "<table class ='table-bordered'>";
while ($row = $mysql->fetch($result)) {
$food_cata_info['name'][$row['food_id']] = $row['food_name'];
$food_cata_info['price'][$row['food_id']] = $row['price'];
$food_cata_info['cata'][$row['food_id']] = $row['cata_name'];
}
$datetime = date('m-d-y h:i:s', time());
echo "<th colspan='4'><span style='font-size: 26px;'>New Order</span> {$datetime}</th>";
echo "<tr class='bold'><td>Food Type</td><td>Food Name</td><td>Price</td><td>Quantity</td></tr>";
$totalid = $mysql->fetch($mysql->query('select count(*) from food_catalogue;'))[0];
$create_res = array();
$totalp = 0;
$itemcount = 0;
for ($f_id = 11; $f_id < $totalid; $f_id++) {
$f_quantity = $_POST[$f_id];
if (!empty($_POST[$f_id])) {
echo "<tr><td>" . $food_cata_info['cata'][$f_id] . "</td>";
示例6: text
static function text($text)
{
$content = "";
$related = 0;
$rel_tooltips = "";
$lines = explode("\n", $text);
$list = false;
foreach ($lines as $line) {
$line = trim($line);
$first_char = substr($line, 0, 1);
if (!$list and "=" == $first_char) {
$content .= "<ul>";
} else {
if ($list and "=" != $first_char) {
$content .= "</ul>";
}
}
$list = $first_char === "=";
if ($list) {
$text = "<li>" . htmlspecialchars(trim(substr($line, 1, 999))) . "</li>";
} else {
$text = "<p>" . htmlspecialchars($line) . "</p>";
}
$text = str_replace("[**", "<span class=\"info\">", $text);
$text = str_replace("**]", "</span>", $text);
$text = str_replace("{{", "<em>", $text);
$text = str_replace("}}", "</em>", $text);
$text = str_replace("[[", "<strong>", $text);
$text = str_replace("]]", "</strong>", $text);
// process related
if ('%' == $first_char) {
list($head, $id_prods) = explode('|', trim(substr($line, 1, 999)));
MySQL::query("SELECT id, cat, link, brand, title, brief, price FROM products WHERE shown=1 AND id IN ({$id_prods}) ORDER BY FIELD (id, {$id_prods})");
if (0 == MySQL::rows()) {
continue;
}
$related++;
$i = 0;
$prods = array();
while ($row = MySQL::fetch()) {
list($id, $cat, $link, $brand, $title, $brief, $price) = $row;
$prods[$i++] = array($id, $cat, $link, $brand, $title, $brief, $price);
}
if ($_SERVER["REMOTE_ADDR"] == "109.99.148.134xx") {
$text = '<div class="row"><div class="col-md-12">';
$text .= '<div class="carousel slide">';
$text .= '<div class="carousel-inner">';
$text .= 'test';
$text .= '</div></div></div></div>';
}
$text = "<strong>{$head}</strong><ul id=\"related{$related}\" class=\"related-skin\">";
foreach ($prods as $prod) {
list($id, $cat, $link, $brand, $title, $brief, $price) = $prod;
$text .= "<li id='rel_{$id}'>" . show_small_image($link, "");
$text .= "<input type='hidden' value='/{$cat}/" . urlencode($link) . "'>";
$text .= "<div class='title'>{$title}</div>";
$text .= "<div class='brand'>{$brand}</div>";
$text .= "<div class='price'><strong>" . ($price + 0) . "</strong> LEI</div>";
$text .= "</li>";
$rel_tooltips .= "\t\$('#rel_{$id}').poshytip({ content: '" . str_replace("'", "\\'", $brief) . "', className: 'tip-darkgray', showTimeout: 100 });\n";
}
$text .= "</ul>";
}
// process links
$offset = 0;
while (true) {
$beg = strpos($text, "<<", $offset);
if (false === $beg) {
break;
}
$end = strpos($text, ">>", $beg);
if (false === $end) {
$end = strlen($text);
}
$text1 = substr($text, 0, $beg);
$text2 = substr($text, $beg + 8, $end - $beg - 8);
$text3 = substr($text, $end + 8);
list($link, $text) = explode("|", $text2);
if (!$text) {
$text = $uri;
}
$text2 = "<a href='{$link}'>{$text}</a>";
$text = $text1 . $text2 . $text3;
$offset = $end;
}
$content .= $text;
}
if ($line) {
$content .= "</ul>";
}
if ($related) {
$content .= "\n" . '<script type="text/javascript">' . "\n";
$content .= '$(document).ready(function() {' . "\n";
for ($i = 1; $i <= $related; $i++) {
$content .= "\t" . '$("#related' . $i . '").jcarousel();' . "\n";
}
$content .= $rel_tooltips;
$content .= "});\n</script>\n";
}
return $content;
//.........这里部分代码省略.........