本文整理汇总了PHP中MySQL::Query方法的典型用法代码示例。如果您正苦于以下问题:PHP MySQL::Query方法的具体用法?PHP MySQL::Query怎么用?PHP MySQL::Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySQL
的用法示例。
在下文中一共展示了MySQL::Query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dupeCheck
public function dupeCheck($name)
{
$db = new MySQL(true, 'color64', 'localhost', 'color64', 'nu5Jc4JdtZK4RCHH');
$q = $db->Query("SELECT `id` FROM `users`");
$allrecords = $db->RowCount();
$q = $db->Query("SELECT `id` FROM `users` WHERE `name` LIKE '" . $name . "';");
if ($db->RowCount() > 0) {
$dupes = $db->Row()->id;
} else {
$dupes = 0;
}
return array('total' => $allrecords, 'dupe' => $dupes);
}
示例2: expense_delete
/**
* delete exp entry
*
* @param integer $id -> ID of record
* @return object
*/
public function expense_delete($id)
{
$filter["expenseID"] = MySQL::SQLValue($id, MySQL::SQLVALUE_NUMBER);
$table = $this->getExpenseTable();
$query = MySQL::BuildSQLDelete($table, $filter);
return $this->conn->Query($query);
}
示例3: Query
function Query ($query)
{
if (DATABASE_TYPE == "PGSQL")
{
return PGSQL::Query ($query);
}
elseif (DATABASE_TYPE == "MYSQL")
{
return MySQL::Query ($query);
}
}
示例4: membership_roles
/**
* @return array|bool
*/
public function membership_roles()
{
$p = $this->kga['server_prefix'];
$query = "SELECT a.*, COUNT(DISTINCT b.userID) as count_users FROM `{$p}membershipRoles` a LEFT JOIN `{$p}groups_users` b USING(membershipRoleID) GROUP BY a.membershipRoleID";
$result = $this->conn->Query($query);
if ($result == false) {
$this->logLastError('membership_roles');
return false;
}
$rows = $this->conn->RecordsArray(MYSQLI_ASSOC);
return $rows;
}
示例5: chapter_show_data
function chapter_show_data($id)
{
$hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
hook_action('chapter_show_data');
if (!$hmdb->Query("SELECT * FROM " . DB_PREFIX . "content WHERE `status` = 'chapter' AND `parent` = '{$id}' ORDER BY id DESC")) {
$hmdb->Kill();
}
$array_cha = array();
while ($row = $hmdb->Row()) {
$data_cha = content_data_by_id($row->id);
$array_cha[] = array('id' => $row->id, 'name' => $row->name, 'slug' => $row->slug, 'public_time' => date('d-m-Y H:i', $data_cha['field']['public_time']));
}
$array['chapter'] = $array_cha;
return hook_filter('chapter_show_data', json_encode($array, TRUE));
}
示例6: request_suggest
function request_suggest($key)
{
$hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
global $hmtaxonomy;
global $hmcontent;
$return = '';
$input_name = hm_post('input', '');
$key = trim($key);
$key = str_replace(' ', '-', $key);
if ($key != '') {
$tableName = DB_PREFIX . 'request_uri';
$hmdb->Query("SELECT * FROM `" . $tableName . "` WHERE `uri` LIKE '%" . $key . "%' LIMIT 10");
while ($row = $hmdb->Row()) {
$id = $row->id;
$object_id = $row->object_id;
$object_type = $row->object_type;
$uri = $row->uri;
$suggest_label = '';
$object_name = '';
switch ($object_type) {
case 'taxonomy':
$tax_data = taxonomy_data_by_id($object_id);
$tax_key = $tax_data['taxonomy']->key;
$taxonomy = $hmtaxonomy->hmtaxonomy;
$suggest_label = $taxonomy[$tax_key]['taxonomy_name'];
$object_name = get_tax_val('name=name&id=' . $object_id);
break;
case 'content':
$con_data = content_data_by_id($object_id);
$con_key = $con_data['content']->key;
$content = $hmcontent->hmcontent;
$suggest_label = $content[$con_key]['content_name'];
$object_name = get_con_val('name=name&id=' . $object_id);
break;
}
$return .= '<li>';
$return .= '<p data-id="' . $id . '" data-input="' . $input_name . '" data-name="' . $object_name . '" object_id="' . $object_id . '" object_type="' . $object_type . '">';
$return .= '<span class="suggest_label">' . $suggest_label . ': </span><b>' . $object_name . '</b>';
$return .= '</p>';
$return .= '</li>';
}
}
return $return;
}
示例7: MySQL
<?php
include "../user/config.php";
include "../core/includes/class/mysql.class.php";
$db = new MySQL(false, $sql_dbname, $sql_host, $sql_user, $sql_pass, $sql_charset, $sql_pcon);
$db->Open();
$result = $db->Query("CREATE TABLE IF NOT EXISTS `ac_global` (\n\t\t`player_identifier` int(11) NOT NULL AUTO_INCREMENT,\n\t\t`player_auth` varchar(36) COLLATE utf8_unicode_ci NOT NULL,\n\t\t`total_tokens` int(11) NOT NULL,\n\t\t`name` varchar(32) COLLATE utf8_unicode_ci NOT NULL,\n\t\tPRIMARY KEY (`player_identifier`),\n\t\tUNIQUE KEY `player_auth` (`player_auth`)\n\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
if (!$result) {
die("MySQL: " . $db->Error() . "");
}
foreach ($servers as $k => $unimportant) {
$result = $db->Query("CREATE TABLE IF NOT EXISTS `ac_{$k}_list` (\n\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t`name` varchar(64) NOT NULL,\n\t\t\t`desc` varchar(256) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,\n\t\t\t`value_id` varchar(32) NOT NULL,\n\t\t\t`icon` varchar(256) NOT NULL,\n\t\t\t`available` int(11) NOT NULL DEFAULT '1',\n\t\t\t`value` int(11) NOT NULL DEFAULT '0',\n\t\t\t`tokens` int(11) NOT NULL DEFAULT '0',\n\t\t\t`max` int(11) NOT NULL DEFAULT '0',\n\t\t\t`created` int(11) NOT NULL DEFAULT '0',\n\t\t\t`cat` int(11) NOT NULL DEFAULT '0',\n\t\t\tPRIMARY KEY (`id`),\n\t\t\tUNIQUE KEY `id` (`id`)\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
if (!$result) {
die("There was an error processing the SQL query. Check if any of the server shorts in config file are incorrect. Only alphanumeric values are allowed.");
}
$result = $db->Query("CREATE TABLE IF NOT EXISTS `ac_{$k}_data` (\n\t\t\t `player_auth` varchar(64) COLLATE utf8_unicode_ci NOT NULL,\n\t\t\t\t`value_id` varchar(32) CHARACTER SET latin1 NOT NULL,\n\t\t\t\t`value_status` int(11) NOT NULL,\n\t\t\t\t`value_extra` int(11) NOT NULL,\n\t\t\t\tPRIMARY KEY (`player_auth`,`value_id`),\n\t\t\t\tKEY `player_auth` (`player_auth`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
if (!$result) {
die("There was an error processing the SQL query. Check if any of the server shorts in config file are incorrect. Only alphanumeric values are allowed.");
}
$result = $db->Query("CREATE TABLE IF NOT EXISTS `ac_{$k}_cats` (\n\t\t\t`cat_id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t`cat_name` varchar(32) NOT NULL,\n\t\t\tPRIMARY KEY (`cat_id`),\n\t\t\tUNIQUE KEY `cat_id` (`cat_id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
if (!$result) {
die("There was an error processing the SQL query. Check if any of the server shorts in config file are incorrect. Only alphanumeric values are allowed.");
}
}
echo "All missing tables (if there were any) were successfully created.";
示例8: array
$User = (string) @$Args['User'];
$Password = (string) @$Args['Password'];
$DbName = (string) @$Args['DbName'];
$Users = (string) @$Args['Users'];
#-------------------------------------------------------------------------------
$Course = 30;
#-------------------------------------------------------------------------------
$Params = array('Server' => $Server, 'Port' => $Port, 'User' => $User, 'Password' => $Password, 'DbName' => $DbName);
#-------------------------------------------------------------------------------
$Link = new MySQL($Params);
#-------------------------------------------------------------------------------
if (Is_Error($Link->Open())) {
return 'Не удалось подключиться к серверу MySQL';
}
#-------------------------------------------------------------------------------
$Result = $Link->Query(SPrintF('SET NAMES `%s`', $Charset));
if (Is_Error($Result)) {
return $Link->GetError();
}
#-------------------------------------------------------------------------------
if (Is_Error($Link->SelectDB())) {
return $Link->GetError();
}
#-------------------------------------------------------------------------------
$Query = 'SELECT * FROM `users`';
#-------------------------------------------------------------------------------
if ($Users) {
#-----------------------------------------------------------------------------
$Users = Preg_Split('/\\s+/', $Users);
#-----------------------------------------------------------------------------
$Array = array();
示例9: user_show_data
/** bảng danh sách thành viên */
function user_show_data($user_group, $perpage)
{
$hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
hook_action('user_show_data');
$request_paged = hm_get('paged', 1);
$paged = $request_paged - 1;
$offset = $paged * $perpage;
$limit = "LIMIT {$perpage} OFFSET {$offset}";
if (!$hmdb->Query("SELECT * FROM " . DB_PREFIX . "users WHERE `user_group` = '{$user_group}' ORDER BY id DESC {$limit}")) {
$hmdb->Kill();
}
if ($hmdb->HasRecords()) {
/* Trả về các user */
while ($row = $hmdb->Row()) {
$array_use[] = array('id' => $row->id, 'user_nicename' => $row->user_nicename, 'user_role' => user_role_id_to_nicename($row->user_role));
}
$array['user'] = $array_use;
/* Tạo pagination */
$hmdb->Query(" SELECT * FROM " . DB_PREFIX . "users WHERE `user_group` = '{$user_group}' ");
$total_item = $hmdb->RowCount();
$total_page = ceil($total_item / $perpage);
$first = '1';
if ($request_paged > 1) {
$previous = $request_paged - 1;
} else {
$previous = $first;
}
if ($request_paged < $total_page) {
$next = $request_paged + 1;
} else {
$next = $total_page;
}
$array['pagination'] = array('first' => $first, 'previous' => $previous, 'next' => $next, 'last' => $total_page, 'total' => $total_item, 'paged' => $request_paged);
} else {
$array['user'] = array();
$array['pagination'] = array();
}
return hook_filter('user_show_data', json_encode($array, TRUE));
}
示例10: MySQL
include_once 'mysql.class.php';
include_once 'dbf_class.php';
$db = new MySQL(true) or die('Cannot connect to MySQL server. Please check settings in mysql.class.php');
// Begin a new transaction, but this time, let's check for errors.
if (!$db->TransactionBegin()) {
$db->Kill();
die('Cannot start DB transactions...quitting now.');
}
// We'll create a flag to check for any errors
$success = true;
global $hkdata;
//sql building: BE CAREFUL NOT TO USE semicolon inside the sql!!!!
$db->TruncateTable("hkmatrix");
//destroy table data
$sql = "CREATE TABLE IF NOT EXISTS `hkmatrix` (\n `uid` int(11) NOT NULL AUTO_INCREMENT,\n `custgroup` varchar(4) NULL,\n `refnum` varchar(10) NULL,\n `prodgroup` varchar(254) NULL,\n `supplier` varchar(254) NULL,\n `prodcode` varchar(16) NULL,\n `matrix` varchar(1) NULL,\n `discount` decimal(10,2) NULL,\n `contract` decimal(10,2) NULL,\n `trade` decimal(10,2) NULL,\n `retail` decimal(10,2) NULL,\n `date_on` date DEFAULT NULL,\n `date_off` date DEFAULT NULL,\n\t`break1` decimal(5,2) NULL,\n\t\n\t`break2` decimal(5,2) NULL,\n\t\n\t`break3` decimal(5,2) NULL,\n\t\n\t`break4` decimal(5,2) NULL,\n\t\n\t`break5` decimal(5,2) NULL,\n\t\n\t`break6` decimal(5,2) NULL,\n\t\n\t`break7` decimal(5,2) NULL,\n\t`price1` decimal(10,2) NULL,`price2` decimal(10,2) NULL,`price3` decimal(10,2) NULL,`price4` decimal(10,2) NULL,`price5` decimal(10,2) NULL,`price6` decimal(10,2) NULL,`price7` decimal(10,2) NULL,\n\t `text` varchar(254) NULL,\n\t `type` varchar(4) NULL,\n PRIMARY KEY (`uid`)\n \n) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
$results = $db->Query($sql);
if (!$results) {
die('Error contacting database!' . $sql);
}
// open in read-write mode
if (function_exists('dbase_open')) {
// only if php was compiled with dbase support
$updatemsg .= "Packing database.<br/>";
$dbo = dbase_open('datastore/hkmatrix.dbf', 2);
// expunge the database
dbase_pack($dbo);
}
$dbr = new dbf_class('datastore/hkmatrix.dbf');
$num_rec = $dbr->dbf_num_rec;
$field_num = $dbr->dbf_num_field;
//print" Num_rec: $num_rec Num_field $field_num <br>";
示例11: header
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Content-type: text/html; charset=utf-8');
}
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) {
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
}
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
}
}
include "mysql.class.php";
$database = new MySQL();
global $database;
if ($database->Query("SELECT mensaje, url FROM kiiconnect_compartir ")) {
$mensajes = $database->RecordsArray();
$tags = array();
if ($mensajes != false) {
foreach ($mensajes as $mensaje) {
$tags['url'] = $mensaje['url'];
$tags['mensaje'] = $mensaje['mensaje'];
}
}
//echo $database->GetJSON();
echo json_encode($tags);
} else {
echo "<p>Query Failed</p>";
}
示例12: removewebstock
function removewebstock()
{
echo "Create/clear update DB...\r\n";
$db = new MySQL(true) or die('Cannot connect to MySQL server. Please check settings in mysql.class.php');
$sql = "CREATE TABLE IF NOT EXISTS `import_webstock` (\n `uid` int(11) NOT NULL AUTO_INCREMENT,\n `prodcode` varchar(16) NOT NULL,\n `descr` varchar(254) NOT NULL,\n `category` varchar(254) NULL,\n `url` varchar(254) NULL,\n `price` decimal(10,2) NOT NULL,\n `trade` decimal(10,2) NOT NULL,\n `wholesale` decimal(10,2) NOT NULL,\n `onorder` int(5) NOT NULL DEFAULT '0',\n `stocklevel` decimal(10,0) NOT NULL,\n `updated` date DEFAULT NULL,\n `webready` tinyint(1) NOT NULL DEFAULT '1',\n `supplier` varchar(254) NULL,\n `brand` varchar(254) NOT NULL,\n `model` varchar(254) NOT NULL,\n PRIMARY KEY (`uid`),\n KEY `prodcode` (`prodcode`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
$results = $db->Query($sql);
//remove then build table
if (!$results) {
die('Error contacting database!' . $sql);
}
$db->TruncateTable("import_webstock");
//destroy table data
}
示例13: query_content
//.........这里部分代码省略.........
$query_join .= " AND `object_id` IN (" . $query_content_key . ") ";
}
if ($query_in_taxonomy) {
$query_join .= " OR `object_id` IN (" . $query_in_taxonomy . ") ";
}
$query_join .= " OR `object_id` IN (" . $query_field . ") ";
break;
case 'and':
if ($query_content_key) {
$query_join .= " AND `object_id` IN (" . $query_content_key . ") ";
}
if ($query_in_taxonomy) {
$query_join .= " AND `object_id` IN (" . $query_in_taxonomy . ") ";
}
$query_join .= " AND `object_id` IN (" . $query_field . ") ";
break;
default:
if ($query_content_key) {
$query_join .= " AND `object_id` IN (" . $query_content_key . ") ";
}
if ($query_in_taxonomy) {
$query_join .= " AND `object_id` IN (" . $query_in_taxonomy . ") ";
}
$query_join .= " AND `object_id` IN (" . $query_field . ") ";
}
/** Kết thúc các query lấy các content id thỏa mãn yêu cầu */
/** Order theo 1 field và limit */
if (isset($args['order'])) {
$order_by = $args['order'];
} else {
$order_by = 'public_time,desc,number';
}
if (isset($args['limit'])) {
$limit = $args['limit'];
} else {
$limit = get_option(array('section' => 'system_setting', 'key' => 'post_per_page', 'default_value' => '12'));
}
if (isset($args['offset']) and is_numeric($args['offset'])) {
$offset = $args['offset'];
} else {
$offset = 0;
}
if (isset($args['paged'])) {
$paged = $args['paged'];
} else {
$paged = get_current_pagination();
}
$paged = $paged - 1;
if ($paged < 0) {
$paged = 0;
}
/** Tạo query ORDER */
$ex = explode(',', $order_by);
$ex = array_map("trim", $ex);
$order_field = $ex[0];
$order = strtoupper($ex[1]);
if (isset($ex[2])) {
$numerically = $ex[2];
} else {
$numerically = FALSE;
}
if ($numerically == 'number') {
$order_query = " AND `name` = '" . $order_field . "' ORDER BY CAST(val AS unsigned) " . $order . " ";
} else {
$order_query = " AND `name` = '" . $order_field . "' ORDER BY `val` " . $order . " ";
}
/** Tạo query LIMIT */
if (is_numeric($limit)) {
$limit_query = " LIMIT {$limit} ";
} else {
$limit_query = '';
}
/** Tạo query OFFSET */
if ($limit == FALSE) {
$offset_query = '';
} else {
$offset_query_page = $paged * $limit;
$offset_query_page = $offset_query_page + $offset;
$offset_query = " OFFSET {$offset_query_page} ";
}
/** Tạo câu lệnh select từ chuỗi các id thỏa mãn */
$result = array();
$sql = "SELECT `object_id`" . " FROM `" . DB_PREFIX . "field`" . " WHERE `object_type` = 'content'" . " " . $query_join . " " . " " . $order_query . " ";
$hmdb->Query($sql);
$total_result = $hmdb->RowCount();
$sql = "SELECT `object_id`" . " FROM `" . DB_PREFIX . "field`" . " WHERE `object_type` = 'content'" . " " . $query_join . " " . " " . $order_query . " " . $limit_query . " " . $offset_query . " ";
$hmdb->Query($sql);
$base = get_current_uri();
if ($base == '') {
$base = '/';
}
$hmcontent->set_val(array('key' => 'total_result', 'val' => $total_result));
$hmcontent->set_val(array('key' => 'paged', 'val' => $paged + 1));
$hmcontent->set_val(array('key' => 'perpage', 'val' => $limit));
$hmcontent->set_val(array('key' => 'base', 'val' => $base));
while ($row = $hmdb->Row()) {
$result[] = $row->object_id;
}
return $result;
}
示例14: backupDatabase
function backupDatabase($dbName, $backupStructure = true, $backupData = true, $backupFile = null)
{
$columnName = 'Tables_in_' . $dbName;
$this->done = false;
$this->output .= "-- SQL Dump File \n";
$this->output .= "-- Generation Time: " . date('M j, Y') . " at " . date('h:i:s A') . " \n\n";
$this->output .= "-- \n";
$this->output .= "-- Database: `{$dbName}` \n";
$this->output .= "-- \n\n";
$conn = new MySQL(true, DBNAME, DBHOST, DBUSER, DBPASS, "", true);
$strTables = 'SHOW TABLES';
$conn->Query($strTables);
$cntTables = $conn->RowCount();
if ($cntTables) {
$conn->MoveFirst();
while (!$conn->EndOfSeek()) {
$rsTables = $conn->Row();
if ($backupStructure) {
$this->dumpTableStructure($rsTables->{$columnName});
}
if ($backupData) {
$this->dumpTableData($rsTables->{$columnName});
}
}
} else {
$this->output .= "-- \n";
$this->output .= "-- No tables in {$dbName} \n";
$this->output .= "-- \n";
}
if (!is_null($backupFile)) {
$this->dumpToFile($backupFile);
}
$this->done = true;
}
示例15: MySQL
<?php
include "mysql.class.php";
$databaseXmltv = new MySQL();
if ($databaseXmltv->Query("SELECT xmltv_canal.id,\n xmltv_canal.nombre as title\n FROM xmltv_canal WHERE activo = 1 ORDER BY orden")) {
$canales = $databaseXmltv->GetJSON();
$data = $databaseXmltv->RecordsArray();
} else {
$canales = "''";
}
//////////////////////////
?>
{
"calendars": <?php
echo $canales;
?>
}