本文整理汇总了PHP中DataBase::Query方法的典型用法代码示例。如果您正苦于以下问题:PHP DataBase::Query方法的具体用法?PHP DataBase::Query怎么用?PHP DataBase::Query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBase
的用法示例。
在下文中一共展示了DataBase::Query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PollMessage
function PollMessage()
{
include 'config/config.php';
require_once 'libs/database.php';
$db = new DataBase($db_server, $db_user, $db_password);
$db->Select($db_name);
$db->Query("SELECT * FROM messages ORDER BY id DESC LIMIT 2");
$data = $db->ReadNext();
//no message in queue - return nop
if ($data == null) {
echo "none";
return;
}
/* echo "<pre>";
print_r($data);
echo "</pre>";*/
$id = $data['id'];
$message = $data['message'];
//return the command to client
echo $message;
//delete message from queue
$db = new DataBase($db_server, $db_user, $db_password);
$db->Select($db_name);
$db->Query("DELETE FROM messages WHERE id = '{$id}';");
}
示例2: EnqueueMessage
function EnqueueMessage($message)
{
include 'config/config.php';
require_once 'libs/database.php';
$db = new DataBase($db_server, $db_user, $db_password);
$db->Select($db_name);
$query = "INSERT INTO messages (\n\t\t\t\t\tmessage\n\t\t\t\t\t)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t'{$message}'\n\t\t\t\t\t);";
$db->Query($query);
}
示例3: _getData
private function _getData()
{
if (is_string($this->dataSource)) {
$db = new DataBase();
$db->Query($this->dataSource);
if ($db->numRows() > 0) {
while ($data = $db->fetchObject()) {
array_push($this->data, $data);
}
} else {
$this->data = NULL;
}
}
if (is_object($this->dataSource) && !is_string($this->dataSource)) {
$this->data = $this->dataSource;
}
if (is_array($this->dataSource)) {
$this->data = $this->dataSource;
}
$this->getDataKeys();
}