本文整理匯總了PHP中MYSQL::query方法的典型用法代碼示例。如果您正苦於以下問題:PHP MYSQL::query方法的具體用法?PHP MYSQL::query怎麽用?PHP MYSQL::query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MYSQL
的用法示例。
在下文中一共展示了MYSQL::query方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: stimulate
public function stimulate(&$hash)
{
$db = new MYSQL();
$db->connect(self::DB_HOST, self::DB_USER, self::DB_PASS, self::DB_DBNAME);
@mysql_query("SET NAMES 'UTF8'");
//must have a string parameter 'action'
LINB::checkArgs($hash, array('string' => array('action' => NULL)));
//handle the process
switch ($hash->action) {
case 'getlist':
return $db->query("select `key`,`value` from `tbl_test`");
case 'update':
//must have string parameters 'key' and 'value'
LINB::checkArgs($hash, array('string' => array('key' => NULL, 'value' => NULL)));
$db->update("tbl_test", array("key" => $hash->key, "value" => $hash->value), "`key`='" . $hash->key . "'");
return 'ok';
case 'delete':
//must have a string parameter 'key'
LINB::checkArgs($hash, array('string' => array('key' => NULL)));
$db->delete("tbl_test", "`key`='" . $hash->key . "'");
return 'ok';
case 'create':
//must have string parameters 'key' and 'value'
LINB::checkArgs($hash, array('string' => array('key' => NULL, 'value' => NULL)));
$db->insert("tbl_test", array("key" => $hash->key, "value" => $hash->value));
return 'ok';
}
}
示例2: stimulate
public function stimulate(&$hash)
{
$db = new MYSQL();
$db->connect(self::DB_HOST, self::DB_USER, self::DB_PASS);
@mysql_query("SET NAMES 'UTF8'");
//must have a string parameter 'action'
LINB::checkArgs($hash, array('string' => array('action' => NULL)));
//handle the process
switch ($hash->action) {
case 'listdbs':
return $db->listdbs();
case 'listtables':
LINB::checkArgs($hash, array('string' => array('dbname' => NULL)));
return $db->listtables($hash->dbname);
case 'list':
LINB::checkArgs($hash, array('string' => array('dbname' => NULL, 'tablename' => NULL, 'page' => 1, 'count' => 20)));
$db->selectdb($hash->dbname);
$count = $db->query("select count(*) from " . $hash->tablename);
$table = $db->query("select * from " . $hash->tablename . " where 1 limit " . ($hash->page - 1) * 20 . ", " . $hash->count, true);
return array($count, $table);
}
}
示例3: MYSQL
<?php
//Set content output to JSON
header("Content-type: application/json");
require '../shared/mysql.php';
// Get data from AngularJS Post
$data = json_decode(file_get_contents("php://input"));
// Sets variables
$email = $data->email;
$password = md5($data->password);
// Creates MySQL object
$mysql = new MYSQL();
// Builds query to insert user into MySQL
$query = "SELECT * FROM users WHERE email = \"{$email}\" AND password=\"{$password}\"";
// Sends user information to MySQL.
$result = $mysql->query($query);
if ($result->num_rows > 0) {
echo json_encode($result->fetch_assoc());
} else {
echo json_encode(false);
}
示例4: json_encode
<?php
//Set content output to JSON
header("Content-type: application/json");
require '../shared/mysql.php';
// Get data from AngularJS Post
$data = json_decode(file_get_contents("php://input"));
// Sets variables
$fname = $data->fname;
$lname = $data->lname;
$email = $data->email;
$password = md5($data->password);
// Creates MySQL object
$mysql = new MYSQL();
// Builds query to insert user into MySQL
$query = "INSERT INTO users (fname, lname, email,password) VALUES (\"{$fname}\",\"{$lname}\",\"{$email}\",\"{$password}\")";
// Sends user information to MySQL.
$mysql->query($query);
echo json_encode(true);
示例5: execute
/**
* Executes a mysql query and returns the results as an array of associative
* arrays of column/value pairs of rows that match the query.
* @param string The query string
* @return array The rows that match the query.
*/
private function execute($query)
{
if ($this->type == 'mysql') {
require "../private/helpers/MYSQL.php";
MYSQL::connect($this->host, $this->user, $this->password, $this->name);
return MYSQL::query($query);
}
}