當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Sql::excute_query方法代碼示例

本文整理匯總了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} &nbsp;&nbsp;&nbsp;&nbsp; <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} &nbsp;&nbsp;&nbsp;&nbsp; <span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span> {$time}</p>";
     }
     return $this->send_ms($response);
 }
開發者ID:Yang-ZL,項目名稱:Cooperative-problem-solving-system,代碼行數:30,代碼來源:class.php

示例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']} &nbsp;&nbsp;&nbsp;&nbsp; <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>
開發者ID:Yang-ZL,項目名稱:Cooperative-problem-solving-system,代碼行數:31,代碼來源:show_all.php


注:本文中的Sql::excute_query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。