本文整理汇总了PHP中DBConnect::runQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnect::runQuery方法的具体用法?PHP DBConnect::runQuery怎么用?PHP DBConnect::runQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnect
的用法示例。
在下文中一共展示了DBConnect::runQuery方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: InboundMessage
define('SMS_PASSWORD', '');
define('SMS_SENDER_NUMBER', '');
try {
// Get the JSON payload sumbitted from SMSified.
$json = file_get_contents("php://input");
// Create a new instance of the custom object.
$sms = new InboundMessage($json);
// Get the message sent with the inbound message.
$message = $sms->getMessage();
// Get the number message was sent from.
$number = $sms->getSenderAddress();
// Look up latest review for establishment.
$conn = new DBConnect(DB_HOST, DB_USER, DB_PASSWORD);
$conn->selectDB(DB_NAME);
$query = str_replace("{NAME}", $conn->escapeInput($message), SQL_QUERY_TEMPLATE);
$result = $conn->runQuery($query);
// Construct response to send back to user.
if ($conn->getNumRowsAffected() == 0) {
$response = "No establishments found";
} else {
$review = mysql_fetch_assoc($result);
$response = 'Name: ' . $review["Est_Name"] . ' ';
$response .= 'Insp. Date: ' . $review["I_Date"] . ' ';
$response .= 'Score: ' . $review["Score"] . ' ';
$response .= 'Grade: ' . $review["Grade"];
}
// Create a new instance of the SMSified object.
$sms = new SMSified(SMS_USER, SMS_PASSWORD);
$sms->sendMessage(SMS_SENDER_NUMBER, $number, $response);
} catch (Exception $ex) {
openlog("DERBYCITYFOOD", LOG_ODELAY, LOG_USER);