本文整理汇总了PHP中run_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP run_sql函数的具体用法?PHP run_sql怎么用?PHP run_sql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_sql函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert_to_vm_panda
function insert_to_vm_panda($id_category, $UURRLL)
{
global $conn;
pq_page($UURRLL);
$res_items = pq('ul.products-grid>li');
foreach ($res_items as $item) {
try {
$ii = pq($item);
$hhq = $ii->html();
$productUrl = $ii->find('a.product-image')->attr('href');
$sql1 = "select count(*) as count from _products where url='{$productUrl}' limit 1";
$res = run_sql($sql1);
// $res = mysql_query($sql1, $conn)or die("Invalid query: " . mysql_error());;
$data = mysql_fetch_assoc($res);
if ($data[count] == 0) {
$imgSmallUrl = $ii->find("img")->attr('taikoo_lazy_src');
$product_name = $ii->find('.product-name>a')->text();
$product_sql = "INSERT _products (url, ids_category, name, img_small, status)\n VALUES ('{$productUrl}', {$id_category}, '{$product_name}', '{$imgSmallUrl}', 1)";
run_sql($product_sql);
} else {
$sql1 = "select * from _products where url='{$productUrl}' limit 1";
$res = run_sql($sql1);
$data2 = mysql_fetch_assoc($res);
$category_old_value = (string) $data2[ids_category];
$sql = " UPDATE _products SET ids_category='{$category_old_value},{$id_category}' WHERE url='{$productUrl}'";
run_sql($sql);
}
} catch (Exception $exc) {
echo $exc->getTraceAsString();
}
}
return $res;
}
示例2: clean_tables
function clean_tables()
{
run_sql("TRUNCATE TABLE jsh_jshopping_categories;");
run_sql("TRUNCATE TABLE\tjsh_jshopping_products;");
run_sql("TRUNCATE TABLE\tjsh_jshopping_products_to_categories;");
run_sql("TRUNCATE TABLE\tjsh_jshopping_products_images;");
}
示例3: print_story
function print_story($sid, $ipos = "right")
{
global $server_name;
global $auth_user;
$story = db_get_rec("story", $sid);
$pipe = db_get_rec("pipe", $story["pid"]);
$topic = db_get_rec("topic", $story["tid"]);
$a["story"] = $story["story"];
$a["time"] = $story["time"];
$a["sid"] = $sid;
$a["ipos"] = $ipos;
$a["topic"] = $topic["topic"];
$a["icon"] = $story["icon"];
$a["title"] = $story["title"];
$a["pid"] = $story["pid"];
$a["ipos"] = $ipos;
$a["zid"] = $pipe["zid"];
if ($sid > 0) {
$row = run_sql("select count(cid) as comments from comment where sid = ?", array($sid));
$a["comments"] = $row[0]["comments"];
} else {
$a["comments"] = 0;
}
print_article($a);
}
示例4: get_captcha_fallback
function get_captcha_fallback()
{
$row = run_sql("select min(captcha_id) as min_id, max(captcha_id) as max_id from captcha");
$min_id = $row[0]["min_id"];
$max_id = $row[0]["max_id"];
$captcha_id = rand($min_id, $max_id);
$row = run_sql("select captcha_id, question, answer from captcha where captcha_id = ?", array($captcha_id));
return array($row[0]["captcha_id"], $row[0]["question"], $row[0]["answer"]);
}
示例5: getLastReportRun
function getLastReportRun($report)
{
$db = db_connect();
$sql = "SELECT *\n FROM reporting.report_log\n WHERE report_name='" . $report . "'\n AND report_code=0\n AND report_endts IS NOT NULL\n\t\t\tAND date(report_startts)=curdate()\n ORDER BY report_endts DESC\n LIMIT 1";
$result = run_sql($db, $sql);
$row = db_fetch_assoc($result[0]);
mysqli_close($db);
return $row;
}
示例6: plugin_mycss_save
function plugin_mycss_save()
{
$css = z(t(v('css')));
$sql = "REPLACE INTO `css` ( `uid` , `css` ) VALUES ( '" . intval(uid()) . "' , '" . s($css) . "' )";
run_sql($sql);
$location = '?c=plugin&a=mycss';
if (db_errno() != 0) {
return info_page('数据保存失败,请稍后重试。<a href="' . $location . '">点击返回</a>');
} else {
header("Location:" . $location);
}
}
示例7: plugin_mycss_save
function plugin_mycss_save()
{
$css = z(t(v('css')));
$sql = "REPLACE INTO `css` ( `uid` , `css` ) VALUES ( '" . intval(uid()) . "' , '" . s($css) . "' )";
run_sql($sql);
$location = '?c=plugin&a=mycss';
if (db_errno() != 0) {
return info_page(__('PL_CSS_MODIFIER_DATE_UPDATE_ERROR', $location));
} else {
header("Location:" . $location);
}
}
示例8: make_atom
function make_atom($topic)
{
global $server_name;
global $server_title;
global $server_slogan;
global $cache_enabled;
$row = run_sql("select sid, pipe.zid, story.time, story.title, story.ctitle, story.story from story inner join pipe on story.pid = pipe.pid order by sid desc limit 10");
if (count($row) > 0) {
$updated = $row[0]["time"];
} else {
$updated = time();
}
$body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$body .= "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n";
$body .= "\t<title type=\"text\">{$server_title}</title>\n";
$body .= "\t<subtitle type=\"text\">{$server_slogan}</subtitle>\n";
$body .= "\t<updated>" . gmdate(DATE_ATOM, $updated) . "</updated>\n";
$body .= "\t<id>http://{$server_name}/atom</id>\n";
$body .= "\t<link rel=\"alternate\" type=\"text/html\" hreflang=\"en\" href=\"http://{$server_name}/\"/>\n";
$body .= "\t<link rel=\"self\" type=\"application/atom+xml\" href=\"http://{$server_name}/atom\"/>\n";
$body .= "\t<icon>http://{$server_name}/favicon.ico</icon>\n";
$body .= "\t<logo>http://{$server_name}/images/logo-feed.png</logo>\n";
for ($i = 0; $i < count($row); $i++) {
$body .= "\t<entry>\n";
$body .= "\t\t<id>http://{$server_name}/story/" . $row[$i]["sid"] . "</id>\n";
$body .= "\t\t<title>" . $row[$i]["title"] . "</title>\n";
$body .= "\t\t<updated>" . gmdate(DATE_ATOM, $row[$i]["time"]) . "</updated>\n";
$body .= "\t\t<link rel=\"alternate\" type=\"text/html\" href=\"http://{$server_name}/story/" . gmdate("Y-m-d", $row[$i]["time"]) . "/" . $row[$i]["ctitle"] . "\"/>\n";
$body .= "\t\t<author>\n";
if ($row[$i]["zid"] == "") {
$body .= "\t\t\t<name>Anonymous Coward</name>\n";
} else {
$body .= "\t\t\t<name>" . $row[$i]["zid"] . "</name>\n";
$body .= "\t\t\t<uri>" . user_page_link($row[$i]["zid"]) . "</uri>\n";
}
$body .= "\t\t</author>\n";
$body .= "\t\t<content type=\"html\">" . htmlspecialchars($row[$i]["story"]) . "</content>\n";
$body .= "\t</entry>\n";
}
$body .= "</feed>\n";
//$date = gmdate("D, j M Y H:i:s") . " GMT");
$time = time();
$etag = md5($body);
if ($cache_enabled) {
//cache_set("atom.$topic.time", $time);
//cache_set("atom.$topic.etag", $etag);
//cache_set("atom.$topic.body", $body);
cache_set(array("atom.{$topic}.time" => $time, "atom.{$topic}.etag" => $etag, "atom.{$topic}.body" => $body));
}
return array($time, $etag, $body);
}
示例9: db_init
function db_init()
{
$password = substr(md5(time() . rand(1, 9999)), rand(1, 20), 12);
$sql_contents = preg_replace("/(#.+[\r|\n]*)/", '', file_get_contents(AROOT . 'misc' . DS . 'install.sql'));
// 更换变量
$sql_contents = str_replace('{password}', md5($password), $sql_contents);
$sqls = split_sql_file($sql_contents);
foreach ($sqls as $sql) {
run_sql($sql);
}
if (db_errno() == 0) {
info_page(__('DATABASE_INIT_FINISHED', $password));
exit;
} else {
info_page(db_error());
exit;
}
}
示例10: dbup
function dbup()
{
$sql = "ALTER TABLE `feed` ADD `comment_count` int(11) NOT NULL DEFAULT '0' ";
run_sql($sql);
$sql = "ALTER TABLE `comment` ADD `device` varchar(16) NOT NULL ";
run_sql($sql);
$sql = "ALTER TABLE `keyvalue` CHANGE `key` `key` VARCHAR( 64 ) NOT NULL";
run_sql($sql);
$sql = "ALTER TABLE `user` ADD `groups` VARCHAR( 255 ) NOT NULL AFTER `desp` ,\nADD INDEX ( `groups` )";
run_sql($sql);
$sql = "CREATE TABLE IF NOT EXISTS `online` (\n `uid` int(11) NOT NULL,\n `last_active` datetime NOT NULL,\n `session` varchar(32) NOT NULL,\n `device` varchar(32) DEFAULT NULL,\n `place` varchar(32) DEFAULT NULL,\n PRIMARY KEY (`uid`),\n KEY `last_active` (`last_active`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8";
run_sql($sql);
$sql = "CREATE TABLE IF NOT EXISTS `plugin` (\n`folder_name` VARCHAR( 32 ) NOT NULL ,\n`on` TINYINT( 1 ) NOT NULL DEFAULT '0',\nPRIMARY KEY ( `folder_name` )\n) ENGINE = MYISAM DEFAULT CHARSET=utf8";
run_sql($sql);
$sql = "ALTER TABLE `todo` ADD `comment_count` INT NOT NULL DEFAULT '0' ";
run_sql($sql);
return info_page(__('DB_UPGRADE_SUCCESS'));
}
示例11: db_init
function db_init()
{
$password = substr(md5(time() . rand(1, 9999)), rand(1, 20), 12);
$sql_contents = preg_replace("/(#.+[\r|\n]*)/", '', file_get_contents(AROOT . 'misc' . DS . 'install.sql'));
// 更换变量
$sql_contents = str_replace('{password}', md5($password), $sql_contents);
$sqls = split_sql_file($sql_contents);
foreach ($sqls as $sql) {
run_sql($sql);
}
if (db_errno() == 0) {
info_page('数据库初始化成功,请使用【member@teamtoy.net】和【' . $password . '】<a href="/" target="new">登入并添加用户</a>');
exit;
} else {
info_page(db_error());
exit;
}
}
示例12: turn
function turn()
{
if (!is_admin()) {
return render(array('code' => LR_API_FORBIDDEN, 'message' => __('API_MESSAGE_ONLY_ADMIN')), 'rest');
}
$on = intval(v('on'));
$folder_name = z(t(v('folder_name')));
if (strlen($folder_name) < 1) {
return render(array('code' => LR_API_ARGS_ERROR, 'message' => 'FOLDER NAME CANNOT BE EMPTY'), 'rest');
}
$sql = "REPLACE `plugin` (`folder_name` , `on`) VALUES ( '" . s($folder_name) . "' , '" . intval($on) . "' )";
run_sql($sql);
if (db_errno() == 0) {
return render(array('code' => 0, 'message' => 'ok'), 'rest');
} else {
return render(array('code' => LR_API_DB_ERROR, 'message' => db_error()), 'rest');
}
}
示例13: plugin_simple_token
function plugin_simple_token()
{
$do = z(t(v('do')));
switch ($do) {
case 'create':
case 'refresh':
$new_token = substr(md5(uid() . time("Y h j G") . rand(1, 9999)), 0, rand(9, 20));
$new_token = uid() . substr(md5($new_token), 0, 10);
$sql = "REPLACE INTO `stoken` ( `uid` , `token` , `on` ) VALUES ( '" . intval(uid()) . "' , '" . s($new_token) . "' , '1' )";
run_sql($sql);
if (db_errno() == 0) {
return ajax_echo('done');
} else {
return ajax_echo('error');
}
break;
case 'close':
$sql = "UPDATE `stoken` SET `on` = '0' WHERE `uid` = '" . intval(uid()) . "' LIMIT 1";
run_sql($sql);
if (db_errno() == 0) {
return ajax_echo('done');
} else {
return ajax_echo('error');
}
break;
case 'reopen':
$sql = "UPDATE `stoken` SET `on` = '1' WHERE `uid` = '" . intval(uid()) . "' LIMIT 1";
run_sql($sql);
if (db_errno() == 0) {
return ajax_echo('done');
} else {
return ajax_echo('error');
}
break;
default:
$data['tinfo'] = get_line("SELECT * FROM `stoken` WHERE `uid` = '" . intval(uid()) . "' LIMIT 1");
render($data, 'ajax', 'plugin', 'simple_token');
}
}
示例14: plugin_system_setting_save
function plugin_system_setting_save()
{
$new_lang = z(t(v('new_lang')));
$sql = "UPDATE `user` SET `language`='" . $new_lang . "' WHERE `id`='" . intval(uid()) . "'";
run_sql($sql);
$sql = "UPDATE ip_br_os_lang SET language='" . $new_lang . "' WHERE ip = '" . $GLOBALS['sys']['ip'] . "' AND browser = '" . $GLOBALS['sys']['browser'] . "' AND browser_ver='" . $GLOBALS['sys']['browser_version'] . "' AND platform= '" . $GLOBALS['sys']['platform'] . "' AND uid='" . intval(uid()) . "'";
run_sql($sql);
plugin_system_setting();
$script = '
<script type="text/javascript" src="static/script/jquery.tablesorter.js"></script>
<script type="text/javascript">
$(function(){
$("#sys_confirm").tablesorter();
toastr.options = {
"closeButton": true,
"debug": false,
"newestOnTop": true,
"progressBar": false,
"positionClass": "toast-top-full-width",
"preventDuplicates": false,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut",
}
toastr.options.onHidden = function() { location.reload(); }
toastr["success"]("' . __('PL_SYS_SUCCESS') . '", "' . __('PL_SYS_RELOADING') . '");
});</script>';
return ajax_echo($script);
}
示例15: get_add_to_waitlist_sql
function get_add_to_waitlist_sql($UnityId, $conn)
{
$sql = "SELECT DISTINCT\n p.\"TYPE\",\n p.\"IDENTIFIER\",\n p.\"Location\",\n p.\"IsAvailable\"\n FROM PUBLICATIONS p\n WHERE p.\"IsAvailable\" = 'N'\n AND (p.\"TYPE\",p.\"IDENTIFIER\") NOT IN\n \t\t(SELECT p3.\"TYPE\",p3.\"IDENTIFIER\" \n \t\t FROM PUBLICATIONS p3\n \t\t WHERE p3.\"IsAvailable\" = 'Y')\n MINUS\n SELECT DISTINCT\n p1.\"TYPE\",\n p1.\"IDENTIFIER\",\n p1.\"Location\",\n p1.\"IsAvailable\"\n FROM PUBLICATIONS p1\n WHERE (p1.\"TYPE\", p1.\"IDENTIFIER\") IN\n (SELECT w.\"Type\", w.\"Identifier\"\n FROM ALAKSHM6.PUBLICATION_WAITLIST w\n WHERE w.\"UnityId\" = '{$UnityId}'\n UNION\n SELECT d.\"Type\", d.\"Identifier\"\n FROM PUBLICATION_DETAILS d\n WHERE d.\"IsReserved\" = 'Y'\n AND d.\"Identifier\" IN\n (SELECT r.\"Title\"\n FROM RESERVES r\n WHERE SYSTIMESTAMP BETWEEN r.\"StartTime\"\n AND r.\"ExpiryTime\"\n AND r.\"CourseId\" NOT IN\n (SELECT e.\"CourseID\"\n FROM ENROLLS e\n WHERE e.\"UnityID\" =\n '{$UnityId}'\n AND SYSTIMESTAMP BETWEEN e.\"StartDate\"\n AND e.\"EndDate\"))\n UNION\n SELECT p2.\"TYPE\", p2.\"IDENTIFIER\"\n FROM ALAKSHM6.PUBLICATIONS p2\n WHERE p2.\"ID\" IN\n (SELECT c.\"ID\"\n FROM PUBLICATION_CHECKOUT c\n WHERE c.\"UnityId\" = '{$UnityId}'\n AND c.\"ReturnDate\" = CAST('31/DEC/9999' AS TIMESTAMP)))";
return run_sql($conn, $sql);
}