本文整理汇总了PHP中MySql::query方法的典型用法代码示例。如果您正苦于以下问题:PHP MySql::query方法的具体用法?PHP MySql::query怎么用?PHP MySql::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySql
的用法示例。
在下文中一共展示了MySql::query方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateUnicode
function updateUnicode()
{
$db = new MySql(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DB);
$sql = "SELECT\r\n `id`,\r\n `character`\r\n FROM\r\n `tomoe_character`\r\n WHERE\r\n `unicode` = 0\r\n LIMIT 0,5000;";
$result = $db->query($sql);
$num_before = $db->num_rows;
if ($num_before > 0) {
$usc_4 = 0;
foreach ($result as $r) {
$usc_4 = utf8ToUnicode($r->character);
$sql = " UPDATE\r\n tomoe_character\r\n SET\r\n unicode = {$usc_4['0']}\r\n WHERE id = {$r->id};";
//echo $sql;
$db->update($sql);
}
echo "请刷新页面。" . time();
} else {
echo "Unicode字段更新完毕";
}
}
示例2: valid_session
function valid_session()
{
$res = MySql::query_row("SELECT count(id) as count_s FROM " . $this->session_table . " WHERE id='" . $this->getSessionID() . "'");
if ($res['count_s'] == 0) {
$rez = MySql::query("INSERT INTO " . $this->session_table . " VALUES ('" . $this->getSessionID() . "'," . time() . ",'" . $GLOBALS['REMOTE_ADDR'] . "')");
$this->s_touch();
}
$this->loadvars();
// $this->gc();
$res = MySql::query_row("SELECT count(id) as count_s FROM " . $this->session_table . " WHERE id='" . $this->getSessionID() . "'");
if ($res['count_s'] != 0) {
return true;
} else {
return false;
}
}
示例3: MySql
<?php
/**
* Created by PhpStorm.
* User: john
* Date: 2015/9/22
* Time: 15:05
*/
include_once "utils/Tables.php";
include_once "utils/MySql.php";
define("SET_READ", "UPDATE " . TABLE_HISTORY . " SET `isRead` = '1' WHERE `id`=");
if (is_array($_GET) && count($_GET) > 0) {
if (isset($_GET["id"])) {
$id = $_GET["id"];
}
}
$mysql = new MySql();
if (isset($id) && $id > 0) {
$mysql->query(SET_READ . $id);
echo $mysql->affectedrows();
} else {
echo "参数错误";
}
示例4: setUtf8
function setUtf8()
{
return MySql::query("SET NAMES utf8");
}
示例5: MySql
include 'thinksaas/sql/' . $select_sql . '.php';
$db = new MySql($arrdb);
include 'thinksaas/tsApp.php';
// MySQL数据库缓存
include 'thinksaas/tsMySqlCache.php';
$tsMySqlCache = new tsMySqlCache($db);
if ($db) {
$sql = file_get_contents('install/install.sql');
$sql = str_replace('ts_', $pre, $sql);
$array_sql = preg_split("/;[\r\n]/", $sql);
foreach ($array_sql as $sql) {
$sql = trim($sql);
if ($sql) {
if (strstr($sql, 'CREATE TABLE')) {
preg_match('/CREATE TABLE ([^ ]*)/', $sql, $matches);
$ret = $db->query($sql);
} else {
$ret = $db->query($sql);
}
}
}
// 存入管理员数据
$salt = md5(rand());
$userid = $db->query("insert into " . $pre . "user (`pwd` , `salt`,`email`) values ('" . md5($salt . $password) . "', '{$salt}' ,'{$email}');");
$db->query("insert into " . $pre . "user_info (`userid`,`username`,`email`,`isadmin`,`addtime`,`uptime`) values ('{$userid}','{$username}','{$email}','1','" . time() . "','" . time() . "')");
// 更改网站信息
$db->query("update " . $pre . "system_options set `optionvalue`='{$site_title}' where `optionname`='site_title'");
$db->query("update " . $pre . "system_options set `optionvalue`='{$site_subtitle}' where `optionname`='site_subtitle'");
$db->query("update " . $pre . "system_options set `optionvalue`='{$site_url}' where `optionname`='site_url'");
$db->query("update " . $pre . "system_options set `optionvalue`='{$site_url}' where `optionname`='link_url'");
$arrOptions = $db->fetch_all_assoc("select * from " . $pre . "system_options");
示例6: _query
/**
* @param string $sql
* @param bool $noexcept
* @return bool|stdClass
*/
public function _query($sql, $noexcept = false)
{
return $this->driver->query($sql, $noexcept);
}
示例7: MySql
include_once "utils/MySql.php";
define("REGISTER", "INSERT INTO " . TABLE_USER . " (`name`, `password`) VALUE ");
define("QUERY_ALL", "SELECT `id` FROM " . TABLE_USER . " WHERE name=");
if (is_array($_GET) && count($_GET) > 0) {
if (isset($_GET["name"])) {
$name = $_GET["name"];
}
if (isset($_GET["password"])) {
$password = $_GET["password"];
}
}
if (!isset($name)) {
echo "用户名不能为空";
return;
}
if (!isset($password)) {
echo "密码不能为空";
return;
}
$mysql = new MySql();
$sql = QUERY_ALL . "'" . $name . "'";
$mysql->query($sql);
$result = $mysql->affectedrows();
if ($result >= 1) {
echo "该用户名已被注册";
return;
}
$sql = REGISTER . "('" . $name . "', '" . $password . "')";
$mysql->query($sql);
$result = $mysql->affectedrows();
echo $result;
示例8: iconv
}
$img_path = $img_path . $_FILES['file']['name'];
$target_path = ".." . $img_path;
$target_path = iconv("UTF-8", "gb2312", $target_path);
if (!move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
echo $target_path;
echo "服务器保存文件失败";
} else {
chmod($target_path, 511);
$history = new History(null, $user, null, $img_path, null, null, null);
/**
* 插入
*/
$sql = $history->getInsertSql(TABLE_HISTORY, $user);
$mysql = new MySql();
$mysql->query($sql);
/**
* 查询
*/
$sql = "SELECT `id` FROM " . TABLE_HISTORY . " WHERE img='" . $img_path . "'";
$result = $mysql->query($sql);
$value = $mysql->fetcharray($result);
$history = History::getHistory($value);
echo $history->id;
/**
* 开启匹配程序
*/
$fp = fsockopen("localhost", 80);
fputs($fp, "GET /logodoctor/php/processCore.php?path={$target_path}\r\n\r\n");
fclose($fp);
}
示例9: JsonHandler
<?php
// hangreHandler.php
require_once $_SERVER['DOCUMENT_ROOT'] . '/hangee/m/lib/__core.php';
$handler = new JsonHandler();
$request = $handler->getRequest();
if ($request == null) {
$handler->sendError('Invalid Request!');
die;
}
$char = $request->character;
$query = "select * from hangee_words where word like '{$char}%' and page < 500 order by word asc";
$db = new MySql();
$db->connect();
$res = $db->query($query);
$words = array();
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
$current = new WordRecord();
$current->wid = $row['id'];
$current->page = $row['page'];
$current->word = $row['word'];
$current->sense = $row['sense'];
$words[] = $current;
}
$db->close();
$handler->sendData($words);
示例10: MySql
<?php
/**
* Created by PhpStorm.哈哈
* User: john
* Date: 2015/9/18
* Time: 19:34
*/
include_once "utils/Tables.php";
include_once "utils/MySql.php";
include_once "model/Logo.php";
define("QUERY_ALL", "SELECT `id`, `name`, `img`, `extra`, `category` FROM " . TABLE_LOGO);
define("QUERY_ID", "SELECT * FROM " . TABLE_LOGO . " WHERE id=");
if (is_array($_GET) && count($_GET) > 0) {
if (isset($_GET["id"])) {
$id = $_GET["id"];
}
}
$mysql = new MySql();
if (isset($id)) {
$result = $mysql->query(QUERY_ID . $id);
$value = $mysql->fetcharray($result);
echo Logo::getJson($value);
} else {
$result = $mysql->query(QUERY_ALL);
$arr = $mysql->fetchall($result);
echo Logo::getJsons($arr);
}
示例11: MySql
*/
include_once "utils/Tables.php";
include_once "utils/MySql.php";
include_once "model/History.php";
include_once "model/Logo.php";
define("QUERY_STATE", "SELECT * FROM " . TABLE_HISTORY . " WHERE `id` IN");
if (is_array($_GET) && count($_GET) > 0) {
if (isset($_GET["ids"])) {
$ids = $_GET["ids"];
}
}
if (!isset($ids)) {
echo "请求参数错误";
} else {
$mysql = new MySql();
$result = $mysql->query(QUERY_STATE . "(" . $ids . ")");
$arr = $mysql->fetchall($result);
$histories = History::getHistorys($arr);
if ($histories) {
foreach ($histories as $history) {
if (!$history->logoId) {
/**
* 查看是否处理完毕
*/
$imgPath = $history->img;
$filePath = ".." . $imgPath . ".txt";
if (is_file($filePath)) {
/**
* 处理完毕,更新数据库
*/
$file = fopen($filePath, "r");
示例12: explode
// Вывод заголовка;
header('Content-type: text/plain; charset=utf-8');
// Проверка версии (iOS);
if (is_version('IOS', 1, 6, 3)) {
// Вывод данных;
//echo json_encode(array('application_lock' => 'Версия приложения устарела'));
//die();
}
// Проверка версии (Android);
if (is_version('ANDROID', 2, 4, 12)) {
// Вывод данных;
//echo json_encode(array('application_lock' => 'Версия приложения устарела'));
//die();
}
// Обработка параметров;
list($file, $type) = explode(".", basename($_SERVER['REQUEST_URI']) . '.api');
// Подключение настроек;
include $_SERVER['DOCUMENT_ROOT'] . '/config.php';
// Подключение MySQL;
include $_SERVER['DOCUMENT_ROOT'] . '/systems/mysql.php';
// Подключение основных функций;
include $_SERVER['DOCUMENT_ROOT'] . '/systems/functions.php';
// Создание объекта MySQL;
$db = new MySql();
$db->connect($db_host, $db_name, $db_user, $db_password);
// Кодировка;
$db->query("SET NAMES `UTF8`");
// Часовой пояс;
$db->query("SET TIME_ZONE='+06:00'");
// Подключение файла;
include $_SERVER['DOCUMENT_ROOT'] . '/systems/api/' . $file . '.php';
示例13: MySql
* Created by PhpStorm.
* User: john
* Date: 2015/9/21
* Time: 20:06
*/
include_once "utils/Tables.php";
include_once "utils/MySql.php";
include_once "model/History.php";
define("QUERY_ALL", "SELECT * FROM " . TABLE_HISTORY . " WHERE `userName`=");
define("QUERY_BY_MINID", "SELECT * FROM " . TABLE_HISTORY . " WHERE id<");
define("ORDER", " ORDER BY createTime DESC");
define("LIMIT", " LIMIT 10");
if (is_array($_GET) && count($_GET) > 0) {
if (isset($_GET["maxId"])) {
$maxId = $_GET["maxId"];
}
if (isset($_GET["user"])) {
$user = $_GET["user"];
}
}
if (!isset($user)) {
return;
}
$mysql = new MySql();
if (isset($maxId) && $maxId > 0) {
$result = $mysql->query(QUERY_BY_MINID . $maxId . " AND `userName`=" . "'{$user}'" . ORDER . LIMIT);
} else {
$result = $mysql->query(QUERY_ALL . "'{$user}'" . ORDER . LIMIT);
}
$arr = $mysql->fetchall($result);
echo History::getJsons($arr);