本文整理匯總了PHP中Sql::excute_query方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sql::excute_query方法的具體用法?PHP Sql::excute_query怎麽用?PHP Sql::excute_query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sql
的用法示例。
在下文中一共展示了Sql::excute_query方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: search
public function search()
{
$response = "";
$sqlhandler = new Sql();
if ($this->client) {
$sql = "SELECT * FROM `choice` WHERE content LIKE '%{$this->content}%' LIMIT 0, 1 ";
} else {
$sql = "SELECT * FROM `choice` WHERE content LIKE '%{$this->content}%'";
}
if ($result = $sqlhandler->excute_query($sql)) {
if ($result->num_rows == 0) {
return $this->send_ms("暫時還沒有隊友碰到這題。");
}
while ($row = $result->fetch_assoc()) {
$key = htmlspecialchars(strtoupper($row['c_key']));
$time = date('g:i A d / M / Y D', $row['c_time']);
$content = htmlspecialchars(stripcslashes($row['content']));
$user = htmlspecialchars(stripcslashes($row['c_user']));
if ($this->client) {
$response .= $content . "|" . $key . "|" . $user;
} else {
$response .= "<p><strong>題目:</strong><span><pre>{$content}</pre></span></p><p><strong>答案:</strong><span class=\"answer\">{$key}</span></p><p class=\"post_info\"><span class=\"glyphicon glyphicon-user\" aria-hidden=\"true\"></span> {$user} <span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span> {$time}</p>";
}
//$response .= "{\"content\": \"{$content}\", \"key\": \"{$key}\", \"user\": \"{$user}\", \"time\": \"{$time}\"},";
}
//$response = rtrim($response, ',') . "]";
//<p><strong>題目:</strong><span><pre>{$content}</pre></span></p><p><strong>答案:</strong><span class=\"answer\">{$key}</span></p><p class=\"post_info\"><span class=\"glyphicon glyphicon-user\" aria-hidden=\"true\"></span> {$user} <span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span> {$time}</p>";
}
return $this->send_ms($response);
}
示例2: Sql
<?php
require_once $_SERVER["DOCUMENT_ROOT"] . "/page.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/class.php";
show_header("提交測試");
$response = " ";
$sqlhandler = new Sql();
$sql = "SELECT * FROM choice WHERE 1";
if ($result = $sqlhandler->excute_query($sql)) {
$p_total = $result->num_rows;
if ($p_total == 0) {
$response = "暫時還沒有隊友碰到這題。";
}
while ($row = $result->fetch_assoc()) {
$key = htmlspecialchars(strtoupper($row['c_key']));
$time = date('g:i A d / M / Y D', $row['c_time']);
$content = htmlspecialchars(stripcslashes($row['content']));
$response .= "<div class=\"search_result\"><p><strong>題目{$row['id']}:</strong><span><pre>{$content}</pre></span></p><p><strong>答案:</strong><span class=\"answer\">{$key}</span></p><p class=\"post_info\"><span class=\"glyphicon glyphicon-user\" aria-hidden=\"true\"></span> {$row['c_user']} <span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span> {$time}</p></div>";
}
}
?>
<div class="cover result">
<p>已提交<strong> <?php
echo $p_total;
?>
</strong>題,題目編號為提交次序。</p>
<?php
echo $response;
?>
</div>