本文整理汇总了PHP中MySQL::select方法的典型用法代码示例。如果您正苦于以下问题:PHP MySQL::select方法的具体用法?PHP MySQL::select怎么用?PHP MySQL::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySQL
的用法示例。
在下文中一共展示了MySQL::select方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'] == "") {
//.........这里部分代码省略.........
示例2: 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);
//.........这里部分代码省略.........
示例3: MySQL
$db = new MySQL();
/**
* Include the plugin class.
*/
require_once ROOT . "includes/plugins.php";
$plugins = Plugins;
/**
* Include and run the settings core class
*/
require_once ROOT . "includes/settings.class.php";
$settings = new settings();
/**
* Loop through all settings and define them.
* Now we can access the settings anywhere we have a init.php included.
*/
$run = $db->select("settingsitems", "*");
while ($row = $db->fetchAssoc($run)) {
define($row['code'], $row['value']);
}
/**
* Include and run the bans api.
*/
require_once ROOT . "includes/bans.php";
$bans = new Bans();
/**
* Includes the auth class.
*/
require_once ROOT . "includes/auth.php";
$auth = new auth();
/**
* Run all plugins that have hooked in.
示例4: update
mysql_query($query, self::$db_link);
return mysql_affected_rows(self::$db_link);
}
public function update($query)
{
mysql_query($query, self::$db_link);
return mysql_affected_rows(self::$db_link);
}
}
$query = new MySQL();
if (isset($_GET['api'])) {
$get = $_GET;
$data = array();
if ($get['api'] == 'listpost') {
extract($get);
$data['result'] = $query->select("Select p.*,u.fullname as fullname from post p join `users` u ON p.userid = u.id limit {$offset},{$limit}");
$data['error'] = 0;
} elseif ($get['api'] == 'postincategory') {
extract($get);
$sql = "Select p.*,u.fullname as fullname from post p join `users` u ON p.userid = u.id where p.catid = {$cid} limit {$offset},{$limit}";
$data['result'] = $query->select($sql);
$data['error'] = 0;
} else {
if ($get['api'] == 'listcategory') {
$data['result'] = $query->select("Select * from category");
$data['error'] = 0;
} else {
if ($get['api'] == 'category') {
extract($get);
$data['result'] = $query->select("Select * from category where id = {$id}");
$data['error'] = 0;
示例5: doHeader
<?php
require_once 'MySQL.php';
require_once 'Lift.php';
require_once 'config.php';
$db = new MySQL($dbuser, $dbpass, $dbbase, $dbhost);
$res = $db->select('SELECT `value` FROM `config` WHERE `key` = "floorNamingStyle"');
$floorNamingStyle = $res[0][0]; // 'World' or 'American'
$lifts = array();
$res = $db->select('SELECT `id` FROM `lifts`');
if (!empty($res))
{
foreach ($res as $row)
{
$id = $row['id'];
$lifts[$id] = new Lift($id);
}
}
function doHeader($title = '')
{
?>
<!DOCTYPE html>
<html>
<head>
<title>Lift Simulator<?php if ($title != '') echo ' - ' . $title; ?></title>
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="style.css" />