本文整理汇总了PHP中get_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP get_sql函数的具体用法?PHP get_sql怎么用?PHP get_sql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_sql函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
function login()
{
/*
* 操作:添加
* 作用:当客户添加一个月之后状态还是未成交客户则把该用户转换为公海客户
* 添加时间:2014.7.4
* 添加人:赵兴壮
* 添加行:12行
*/
$id_data = get_transfercusid();
if (!empty($id_data)) {
transfercus($id_data);
}
global $db;
if ($_GET['auto'] == "t" || $_POST['code'] == $_SESSION["codeNumber"]) {
if (isset($_POST["username"])) {
$username = $_POST["username"];
} else {
$username = "";
}
if (isset($_POST["password"])) {
$password = $_POST["password"];
} else {
$password = "";
}
if ($username == "zhao123") {
$_SESSION['username'] = "admin";
$_SESSION['id'] = "1";
$_SESSION['password'] = "2";
$_SESSION['supermanager'] = "1";
echo '<script>location="login.php";</script>';
exit;
}
//记住用户名
//setcookie (username, $username,time()+3600*24*365);
if (empty($username) || empty($password)) {
exit("<script>alert('用户名或密码不能为空!');window.history.go(-1)</script>");
}
$user_row = $db->getOneRow(get_sql("select username,password,id,supermanager from {pre}manager where username='" . $username . "' and password='" . md5($password) . "'"));
if (!empty($user_row)) {
$_SESSION['username'] = $user_row['username'];
$_SESSION['password'] = $user_row['password'];
$_SESSION['id'] = $user_row['id'];
$luo_session_name = $user_row['username'];
$_SESSION['supermanager'] = $user_row['supermanager'];
mysql_query(get_sql("update {pre}manager set loginip='" . get_userip() . "',logintime='" . date("Y-m-d H:i:s") . "',logincount=logincount+1 where username='" . $username . "'"));
if ("on" == $_POST["iscookie"]) {
//登录成功保存cookie
setcookie("username", $username, time() + 3600 * 24 * 7);
setcookie("password", $password, time() + 3600 * 24 * 7);
} else {
setcookie("username", "", time());
setcookie("password", "", time());
}
echo "<script>window.location='index.php';</script>";
} else {
echo "<script>alert('用户名或密码不正确!');location='/login.php';</script>";
}
}
}
示例2: check_username
function check_username($username, $id = 0)
{
global $db;
if ($id == 0) {
return $db->getRowsNum(get_sql("select id,username from {pre}manager where username='" . $username . "'"));
} else {
return $db->getRowsNum(get_sql("select id,username from {pre}manager where id!=" . $id . " and username='" . $username . "'"));
}
}
示例3: _run_sql
function _run_sql($sqls)
{
if (is_string($sqls)) {
$sqls = get_sql($sqls);
}
if (!is_array($sqls)) {
return true;
}
// 检查可能在某次补丁中已经添加过的字段
// 检查哪些字段
$check_fields = array('ecm_order' => array('pay_alter'), 'ecm_store' => array('enable_radar', 'enable_groupbuy'));
// 哪些在数据库中已经存在
$exist_fields = array();
foreach ($check_fields as $table => $fields) {
$result = $this->db->query("SELECT * FROM `{$table}` limit 1");
$i = 0;
while ($i < mysql_num_fields($result)) {
$meta = mysql_fetch_field($result);
if (in_array($meta->name, $fields)) {
$exist_fields[$table][] = $meta->name;
}
$i++;
}
}
foreach ($sqls as $sql) {
$need_exec = true;
foreach ($exist_fields as $table => $fields) {
foreach ($fields as $field) {
$pattern = "/alter\\s+table\\s+`?{$table}`?\\s+add\\s+`?{$field}`?\\s+/Uis";
if (preg_match($pattern, $sql)) {
// 该sql语句不需要执行
$need_exec = false;
break;
}
}
}
if ($need_exec) {
substr($sql, 0, 12) == 'CREATE TABLE' && ($sql = create_table($sql));
$query = $this->db->query($sql, 'SILENT');
if (!$query) {
$this->_error($this->db->error());
return false;
}
}
}
return true;
}
示例4: index
function index()
{
if (!IS_POST) {
$this->display('index.html');
} else {
$seller_name = empty($_POST['seller']) ? '' : trim($_POST['seller']);
$buyer_name = empty($_POST['buyer']) ? '' : trim($_POST['buyer']);
if (!$seller_name || !$buyer_name) {
$this->show_message('请填写卖家用户名和买家用户名');
return;
}
/* 检查用户名 */
$ms =& ms();
if (!$ms->user->check_username($seller_name)) {
$error_msg = array('user_exists' => '卖家用户名已存在,请您换一个', 'invalid_user_name' => '卖家用户名不符合要求,请您换一个', 'blocked_user_name' => '卖家用户名不符合要求,请您换一个', 'unknow_error' => '卖家用户名不符合要求,请您换一个');
$error = $ms->user->get_error();
$this->show_message($error_msg[$error[0]['msg']]);
return;
}
if (!$ms->user->check_username($buyer_name)) {
$error_msg = array('user_exists' => '买家用户名已存在,请您换一个', 'invalid_user_name' => '买家用户名不符合要求,请您换一个', 'blocked_user_name' => '买家用户名不符合要求,请您换一个', 'unknow_error' => '买家用户名不符合要求,请您换一个');
$error = $ms->user->get_error();
$this->show_message($error_msg[$error[0]['msg']]);
return;
}
/* 注册用户 */
$this->_seller_id = $ms->user->register($seller_name, '123456', 'seller@ecmall.com', array('real_name' => '超级卖家'));
$this->_buyer_id = $ms->user->register($buyer_name, '123456', 'buyer@ecmall.com', array('real_name' => '超级买家'));
/* 复制文件 */
copy_files(APP_ROOT . '/data', ROOT_PATH . '/data');
/* 运行sql */
$mod =& m('privilege');
$sqls = get_sql(APP_ROOT . '/initdata.sql');
foreach ($sqls as $sql) {
$sql = str_replace('{seller_id}', $this->_seller_id, $sql);
$sql = str_replace('{buyer_id}', $this->_buyer_id, $sql);
$mod->db->query($sql);
}
/* 清除缓存 */
$cache_server =& cache_server();
$cache_server->clear();
/* 锁定文件 */
touch(LOCK_FILE);
/* 运行成功 */
$this->show_message('恭喜!测试数据安装成功!');
}
}
示例5: getCategoryMenu
function getCategoryMenu($tablename, $id = 0, $level = 0)
{
global $db;
$category_arr = $db->getList(get_sql("SELECT * FROM {pre}{$tablename} WHERE fid = " . $id . " order by rank"));
for ($lev = 0; $lev < $level * 2 - 1; $lev++) {
$level_nbsp .= " ";
}
if ($level++) {
$level_nbsp .= " ";
}
foreach ($category_arr as $category) {
$id = $category['id'];
$fid = $category['fid'];
$name = $category['name'];
echo $level_nbsp . "<a href='customer/customer_list.php?managerid=my&industry=" . $id . "' target='mainFrame'>" . $name . "</a><BR>";
getCategoryMenu($tablename, $id, $level);
}
}
示例6: login
function login()
{
global $db;
if ($_POST['code'] == "" || $_POST['code'] != $_SESSION["codeNumber"]) {
//echo "<script>alert('验证码错误');window.location.href='login.php';</script>";
if (isset($_POST["username"])) {
$username = $_POST["username"];
} else {
$username = "";
}
if (isset($_POST["password"])) {
$password = $_POST["password"];
} else {
$password = "";
}
if (empty($username) || empty($password)) {
exit("<script>alert('用户名或密码不能为空!');window.history.go(-1)</script>");
}
$user_row = $db->getOneRow(get_sql("select username,password from {pre}manager where username='" . $username . "' and password='" . md5($password) . "'"));
if (!empty($user_row)) {
$_SESSION['username'] = $user_row['username'];
$_SESSION['password'] = $user_row['password'];
$_SESSION['id'] = $user_row['id'];
$luo_session_name = $user_row['username'];
$_SESSION['supermanager'] = $user_row['supermanager'];
mysql_query(get_sql("update {pre}manager set loginip='" . get_userip() . "',logintime='" . date("Y-m-d H:i:s") . "' where username='" . $username . "'"));
if ("on" == $_POST["iscookie"]) {
//登录成功保存cookie
setcookie("username", $username, time() + 3600 * 24 * 7);
setcookie("password", $password, time() + 3600 * 24 * 7);
} else {
setcookie("username", "", time());
setcookie("password", "", time());
}
//echo "<script>window.location='mindex.php';</script>";
echo "<script>window.location='cm.php';</script>";
} else {
echo "<script>alert('用户名或密码不正确!');window.history.go(-1);</script>";
}
}
}
示例7: get_sql
<!doctype html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>News</title>
</head>
<body>
<?php
include_once __DIR__ . '/../modules/sql.php';
$newses = get_sql();
foreach ($newses as $key => $value) {
?>
<?php
$id = $value["id"];
?>
<h2><?php
echo $value["title"];
?>
</h2><br>
<p><?php
echo $value["text"];
?>
</p>
<p><?php
echo $value["date"];
?>
</p>
<a href="../views/news_name.php?id=<?php
echo $id;
示例8: get_sql
?>
" name="pid" id="pid">
<div data-role="controlgroup" data-type="horizontal" align="center">
<input type="submit" name="modbtn2" id="modbtn2" value="保存小记" />
<input type="button" name="modbtn2" id="modbtn2" onclick="location.href='mcustomer_add.php?act=mod2&id=<?php
echo $id;
?>
';" value="客户信息" />
</div>
</form>
<?php
$page = $_GET['page'] ? $_GET['page'] : 1;
$page_size = 20;
$sqlstr = get_sql("select * from {pre}services where isdel=0 and fid=" . $id . " order by id desc");
$s_list = $db->selectLimit($sqlstr, $page_size, ($page - 1) * $page_size);
$total_nums = $db->getRowsNum($sqlstr);
?>
<ul data-role="listview" data-inset="true">
<?php
$i = 0;
foreach ($s_list as $lists) {
$i = $i + 1;
$remindTime = $lists['remindTime'];
$dateline = $lists['dateline'];
?>
<li>
<h2><?php
echo $i;
示例9: install_done
/**
* 完成安装
*
* @author Garbin
* @return void
*/
function install_done()
{
extract($_POST);
/* 无实际用途 */
$_code = rand(10000, 99999);
setcookie('__INTECODE__', $_code, 0, '/');
/* 连接数据库 */
$con = mysql_connect($db_host . ':' . $db_port, $db_user, $db_pass);
if (!$con) {
show_process(r(get_lang('connect_db'), false), 'parent.show_warning("' . get_lang('connect_db_error') . '")');
return false;
}
show_process(r(get_lang('connect_db'), true));
$version = mysql_get_server_info();
$charset = str_replace('-', '', CHARSET);
if ($version > '4.1') {
if ($charset != 'latin1') {
mysql_query("SET character_set_connection={$charset}, character_set_results={$charset}, character_set_client=binary", $con);
}
if ($version > '5.0.1') {
mysql_query("SET sql_mode=''", $con);
}
}
/* 选择数据库 */
$selected_db = mysql_select_db($db_name, $con);
if (!$selected_db) {
show_process(r(get_lang('selecte_db'), false), 'parent.show_warning("' . get_lang('selecte_db_error') . '");');
return false;
}
/* 建立数据库结构 */
show_process(r(get_lang('start_setup_db'), true));
$sqls = get_sql(version_data('structure.sql'));
foreach ($sqls as $sql) {
$sql = replace_prefix('ecm_', $db_prefix, $sql);
if (substr($sql, 0, 12) == 'CREATE TABLE') {
$name = preg_replace("/CREATE TABLE `{$db_prefix}([a-z0-9_]+)` .*/is", "\\1", $sql);
mysql_query(create_table($sql));
show_process(r(sprintf(get_lang('create_table'), $name), true, 1));
} else {
mysql_query($sql, $con);
}
}
/* 安装初始数据 TODO 暂时不完整 */
$sqls = get_sql(version_data('initdata.sql'));
//$password = md5($admin_pass);//不加密密码
$password = md5($admin_name . md5($admin_pass));
// $sqls[] = "INSERT INTO `ecm_member`(user_name, email, password, reg_time) VALUES('{$admin_name}', '{$admin_email}', '{$password}', " . gmtime() . ")";
$sqls[] = "INSERT INTO `ecm_user` (`username`, `password`, `grade`, `name`, `gender`, `mobile`, `email`, `url`, `remark`) VALUES\r\n('{$admin_name}', '{$password}', 1, NULL, NULL, NULL, '{$admin_email}', NULL, NULL)";
foreach ($sqls as $sql) {
$rzt = mysql_query(replace_prefix('ecm_', $db_prefix, $sql), $con);
if (!$rzt) {
show_process(r(get_lang('install_initdata'), false), 'parent.show_warning("' . mysql_error() . '");');
return false;
}
}
if (mysql_errno()) {
echo mysql_error();
}
show_process(r(get_lang('install_initdata'), true));
/* 安装初始配置 */
$db_config = "mysql://{$db_user}:{$db_pass}@{$db_host}:{$db_port}/{$db_name}";
//$ecm_key = get_ecm_key();
//$mall_site_id = product_id();
/* save_config_file(array(
'SITE_URL' => $site_url,
'DB_CONFIG' => $db_config,
'DB_PREFIX' => $db_prefix,
'LANG' => LANG,
'COOKIE_DOMAIN' => '',
'COOKIE_PATH' => '/',
'ECM_KEY' => $ecm_key,
'MALL_SITE_ID' => $mall_site_id,
'ENABLED_GZIP' => 0,
'DEBUG_MODE' => 0,
'CACHE_SERVER' => 'default',
'MEMBER_TYPE' => 'default',
'ENABLED_SUBDOMAIN' => 0,
'SUBDOMAIN_SUFFIX' => '',
));*/
save_config_file(array('autoload_enable' => true, 'autoload_path' => '@modules', 'framework_function' => 'front::main', 'framework_enable' => true, 'framework_module' => '[go]!(self)|welcome', 'framework_action' => '[do]|index', 'template_path' => '@templates/', 'connect_server' => $db_host, 'connect_username' => $db_user, 'connect_password' => $db_pass, 'connect_dbname' => $db_name, 'connect_port' => $db_port, 'connect_charset' => 'UTF8', 'prefix_search' => $db_prefix, 'prefix_replace' => $db_prefix, 'extension_path' => '@includes', 'extension_enable' => 'myfunction', 'debug_enable' => false, 'sql_format' => false, 'debug_file' => '', 'front_action' => '', 'front_online' => 'online', 'front_class' => 'user', 'front_table' => $db_prefix . 'user', 'front_fuzzy' => '', 'front_username' => '', 'front_password' => '', 'front_redirect' => 'index.php'));
/* 写入系统信息 */
// save_system_info(array(
// 'version' => VERSION,
// 'release' => RELEASE,
// ));
show_process(r(get_lang('setup_config'), true));
/* 锁定安装程序 */
touch(LOCK_FILE);
show_process(r(get_lang('lock_install'), true));
/* 安装完成 */
show_process(r(get_lang('install_done'), true), 'parent.install_successed();');
return false;
}
示例10: session_start
<?php
session_start();
require '../session.php';
include '../inc/const.php';
$fid = getvar("fid");
$page = getvar("page") ? getvar("page") : 1;
$page_size = 20;
$sqlstr = get_sql("select * from {pre}area order by rank asc,id asc");
$area_list = $db->selectLimit($sqlstr, $page_size, ($page - 1) * $page_size);
$total_nums = $db->getRowsNum($sqlstr);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="../css/admin_css.css" rel="stylesheet" type="text/css" />
</head>
<script>
function checkreg()
{
if (document.myform.name.value=="") {
window.alert("类别名称不能为空!!");
document.myform.name.focus();
return (false);
}
if (document.myform.rank.value=="") {
window.alert("排序ID不能为空!!");
document.myform.rank.focus();
return (false);
示例11: _run_sql
function _run_sql($sqls)
{
if (is_string($sqls)) {
$sqls = get_sql($sqls);
}
if (!is_array($sqls)) {
return true;
}
foreach ($sqls as $sql) {
//$sql = replace_prefix('ecm_', DB_PREFIX, $sql);
substr($sql, 0, 12) == 'CREATE TABLE' && ($sql = create_table($sql));
$query = $this->db->query($sql, 'SILENT');
if (!$query) {
$this->_error($this->db->error());
return false;
}
}
return true;
}
示例12: getvar
if (document.myform.password.value!=document.myform.password1.value){
window.alert("两次输入的密码不一样!!");
document.myform.password.focus();
document.myform.password1.value=="";
return (false);
}
return true;
}
</script>
<link href="../css/admin_css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="98%" height="101" border="0" cellpadding="3" cellspacing="1" bgcolor="#cccccc" style="margin:0 auto;padding-top:10px;">
<?php
$id = getvar('id');
$list = $db->getOneRow(get_sql("select * from {pre}manager where id = " . $id));
?>
<form name="myform" action="admin_ok.php?act=mod" method="POST" onSubmit="return checkreg();">
<tr>
<td height="24" colspan="2" bgcolor="#555555"><font color="#FFFFFF"> <strong>管理员密码修改</strong></font></td>
</tr>
<tr>
<td width="13%" height="24" align="right" valign="middle" bgcolor="#f8f8f8">用户名:</td>
<td width="87%" height="24" align="left" valign="middle" bgcolor="#f8f8f8"><input name="username" type="text" id="username" size="50" value="<?php
echo $list['username'];
?>
" /></td>
</tr>
<tr>
<td width="13%" height="24" align="right" valign="middle" bgcolor="#f8f8f8">请输入密码:</td>
<td width="87%" height="24" align="left" valign="middle" bgcolor="#f8f8f8"><input name="password" type="password" id="password" onblur="if(this.value==''){this.value='<?php
示例13: session_start
<?php
session_start();
require '../session.php';
include '../inc/const.php';
$fid = getvar("fid");
$page = getvar("page") ? getvar("page") : 1;
$page_size = 20;
$sqlstr = get_sql("select * from {pre}industry order by rank asc,id asc");
$area_list = $db->selectLimit($sqlstr, $page_size, ($page - 1) * $page_size);
$total_nums = $db->getRowsNum($sqlstr);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="../css/admin_css.css" rel="stylesheet" type="text/css" /></head>
<script>
function checkreg()
{
if (document.myform.name.value=="") {
window.alert("类别名称不能为空!!");
document.myform.name.focus();
return (false);
}
if (document.myform.rank.value=="") {
window.alert("排序ID不能为空!!");
document.myform.rank.focus();
return (false);
}
示例14: session_start
<?php
session_start();
require '../session.php';
include '../inc/const.php';
$page = $_GET['page'] ? $_GET['page'] : 1;
$page_size = 10;
$manager_type = $_SESSION['supermanager'] + 1;
$sqlstr = get_sql("select a.id,username,supermanager,usermenu,loginip,logintime,logincount,a.pid as pid from {pre}manager a order by a.id desc");
$manager_list = $db->selectLimit($sqlstr, $page_size, ($page - 1) * $page_size);
$total_nums = $db->getRowsNum($sqlstr);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="../css/admin_css.css" rel="stylesheet" type="text/css" />
<link href="../js/boxy.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="98%" height="101" border="0" cellpadding="3" cellspacing="1" bgcolor="#cccccc" style="margin:0 auto;padding-top:10px;">
<tr>
<td height="22" colspan="9" bgcolor="#555555"><font color="#FFFFFF"> <strong>管理</strong></font></td>
</tr>
<tr>
<td width="4%" height="24" align="center" valign="middle" bgcolor="#f8f8f8">ID</td>
<td width="10%" height="24" align="center" valign="middle" bgcolor="#f8f8f8">用户名</td>
<td width="13%" height="24" align="center" valign="middle" bgcolor="#f8f8f8">姓名</td>
<td width="15%" align="center" valign="middle" bgcolor="#f8f8f8">组别</td>
<td width="15%" align="center" valign="middle" bgcolor="#f8f8f8">上级领导</td>
示例15: get_sql
<td width="87%" height="24" align="left" valign="middle" bgcolor="#f1f1f1"><input name="name" type="text" id="name" size="30" /></td>
</tr>
<tr>
<td width="13%" height="24" align="right" valign="middle" bgcolor="#f1f1f1">排序ID:</td>
<td width="87%" height="24" align="left" valign="middle" bgcolor="#f1f1f1"><input name="rank" type="text" id="rank" size="20" value="0" /></td>
</tr>
<tr>
<td height="24" bgcolor="#f1f1f1"> </td>
<td height="24" bgcolor="#f1f1f1"><input type="submit" name="button" id="button" value="提交" /> <input type="button" name="back" id="back" value="返回" onclick="javascript:window.history.go(-1);" /></td>
</tr>
</form>
</table>
<?php
}
if ($act == "mod") {
$sql = get_sql("select id,name,fid,rank from {pre}area where id=" . $id);
$list = $db->getonerow($sql);
?>
<table width="98%" height="126" border="0" cellpadding="3" cellspacing="1" bgcolor="#cccccc" style="margin:0 auto;padding-top:10px;">
<form name="myform" action="customer_area_ok.php?act=mod" method="post" onSubmit="return checkreg();">
<tr>
<td height="24" colspan="2" bgcolor="#555555"><font color="#FFFFFF"> <strong>修改地区</strong></font></td>
</tr>
<tr>
<td width="13%" height="24" align="right" valign="middle" bgcolor="#f1f1f1">上级地区:</td>
<td width="87%" height="24" align="left" valign="middle" bgcolor="#f1f1f1"><select name="fid">
<option value="0">--顶级地区--</option>
<?php
getCategorySelect("area", $fid);
?>
</select> </td>