本文整理汇总了PHP中connect::query方法的典型用法代码示例。如果您正苦于以下问题:PHP connect::query方法的具体用法?PHP connect::query怎么用?PHP connect::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类connect
的用法示例。
在下文中一共展示了connect::query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getToken
function getToken()
{
require_once 'comm.php';
$currnet = time();
$Token_result = new connect();
$sql = "SELECT * FROM options where type='token'";
$result = $Token_result->query($sql);
$arr = mysql_fetch_array($result);
$time_token = $arr['value'];
if ($currnet >= $time_token) {
$appid = "wxa2986e7d8863b2ab";
$secret = "08d000097799e646d11b57e0acd71a9f";
$access_token = file_get_contents("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}");
$access_token = json_decode($access_token);
$access_token = $access_token->{'access_token'};
//修改新的token信息
$time = $currnet + 7200;
$sql = "UPDATE options SET title='" . $access_token . "',value='" . $time . "' where type='token'";
$Token_result->query($sql);
} else {
$access_token = $arr['title'];
//$access_token ="48QToD2xXqQSwSNF8uqn6iF3o3P4yDEqvrrxaDDO0nxqcZFgg95IwA_xAafzwhsVxcM4Hh0tQTtwIcTqFxEa_B1IUpXE67cVUmpBnq_09rE";
}
return $access_token;
}
示例2: connect
<?php
header("Content-type:text/html;charset=utf-8");
require_once 'comm.php';
$page = 0;
$pagesize = 20;
if ($_POST['page']) {
$page = $_POST['page'];
}
$start = $pagesize * $page;
echo "<form action='sendMessage.php' method='post'>\n\t\t\t<table>\t\n\t\t\t\t<input type='hidden' name='page' id='page' value=" . ($page + 1) . " />\n\t\t\t\t<input type='submit' value='NextPage' />\n\t\t\t</table>\n\t </form>";
$connect = new connect();
$list = $connect->query("SELECT * FROM ecs_chat_log ORDER BY time DESC LIMIT {$start},{$pagesize}");
while ($arr = mysql_fetch_array($list)) {
echo $arr['time'] . "=>" . $arr['nickname'] . ":" . $arr['message'] . "<br />";
echo "<form action='sendMessage.php' method='post'>\n\t\t\t<table>\n\t\t\t\t<input type='text' name='message' id='message' />\n\t\t\t\t<input type='hidden' name='openid' id='openid' value=" . $arr['openid'] . " />\n\t\t\t\t<input type='hidden' name='page' id='page' value=" . $page . "/>\n\t\t\t\t<input type='submit' value='send' />\n\t\t\t</table>\n\t </form>";
}
//$result = $connect->query("INSERT INTO ecs_chat_log (openid,message,nickname,time) VALUES('".$openid."','".$Content."','".$nickname."','".$CreateTime."')");
if ($_POST['message'] && $_POST['openid']) {
require_once 'getTokenMessage.php';
$message = $_POST['message'];
$openid = $_POST['openid'];
unset($_POST['message']);
$access_token = getToken();
$content = '{
"touser":"' . $openid . '",
"msgtype":"text",
"text":
{
"content":"' . $message . '"
}