php开发中sql语句拼接示例(插入、查询、更新)
1.插入语句
$sql="insert into Ad(AdClassID,AdType,AdTit,AdFileName,AdUrl,AShow,Addtime) values('".$AdClassID."','".$AdType."','".$AdTit."','".$AdFileName."','".$AdUrl."','1','".$Addtime."')"; |
2.从数据库中选出数据
$sql = "select * from AdClass order by ID desc";<br><br>$sql="select * from admin where AdminID='".$_SESSION['AdminID']."'"; |
$fids = str_replace("|",",",$_POST['fileid2']);//$_POST['fileid2'] == "2246|2247|2248"
$sql2 = "select save_name from xxf_witkey_file where file_id in(".$fids.")";
$b = db_factory::query($sql2);//save_name二维集合数组
3,批量删除
// 1,根据checkbox过来的一维数组, 转成字符串;2、因为是order_id,所有在in 里面使用整型
is_array ( $ckb ) and $ids = implode ( ',', $ckb );
$order_status = 'close'; $res = db_factory::execute("delete from xxf_witkey_home_order where order_id in (".$ids.") and order_status = '".$order_status."'");
4.更新数据库中记录数据
$sql="update Ad set AdClassID='".$AdClassID."',AdType='".$AdType."',AdTit='".$AdTit."',AdFileName='".$AdFileName."',AdUrl='".$AdUrl."',Addtime='".$Addtime."' where ID=".$ID.""; |
$SQl = "update xxf_witkey_activity set subhead='".$subhead."' where a_id=".$a_id."";
5、进行模糊like查询:
$sql = "select * from xxf_witkey_article where cat_type ='article' and is_recommend =1 and art_title like '%".$key_word."%' order by art_id desc ";
php开发中sql语句拼接示例(插入、查询、更新)的更多相关文章
- php开发中sql语句拼接示例
1.插入语句 $sql="insert into Ad(AdClassID,AdType,AdTit,AdFileName,AdUrl,AShow,Addtime) values('&quo ...
- jdbc中SQL语句拼接java变量
例如:String sql = "select * from user where username='" + username + "' and password =' ...
- mybatis中sql语句的批量插入
<!-- 收件箱插入收件信息 --> <insert id="insertReceiveemail"> <!-- 生成一条U ...
- 在EF4.1的DBContext中实现事务处理(BeginTransaction)和直接执行SQL语句的示例
在EF4.1的DBContext中实现事务处理(BeginTransaction)和直接执行SQL语句的示例 (2012-03-13 10:12:48) 转载▼ public ActionResu ...
- oracle 中SQL 语句开发语法 SELECT INTO含义
oracle 中SQL 语句开发语法 SELECT INTO含义 在ORACLE中SELECT INTO是如何使用的,什么意思?和SQL SERVER的不一样? 和sqlserver的不一样sql ...
- [转帖]关于Java中SQL语句的拼接规则
关于Java中SQL语句的拼接规则 自学demo 的时候遇到的问题 结果应该是 '"+e.getName()+"' 注意 一共有三组标点符号 (除去 方法函数后面的括号) 实现目标 ...
- ASPNETCOREAPI 跨域处理 SQL 语句拼接 多条件分页查询 ASPNET CORE 核心 通过依赖注入(注入服务)
ASPNETCOREAPI 跨域处理 AspNetCoreApi 跨域处理 如果咱们有处理过MV5 跨域问题这个问题也不大. (1)为什么会出现跨域问题: 浏览器安全限制了前端脚本跨站点的访问资源, ...
- 自己写的Python数据库连接类和sql语句拼接方法
这个工具类十分简单和简洁. sql拼接方法 # encoding=utf-8 from django.http import HttpResponse from anyjson import seri ...
- 整理:sql server 中sql语句执行顺序
SQL Server 查询处理中的各个阶段(SQL执行顺序) SQL 不同于与其他编程语言的最明显特征是处理代码的顺序.在大数编程语言中,代码按编码顺序被处理,但是在SQL语言中,第一个被处理的子句是 ...
随机推荐
- Android之RAS加密算法测试
import java.security.Key; import java.security.KeyFactory; import java.security.KeyPair; import java ...
- [JQuery] jQuery选择器ID、CLASS、标签获取对象值、属性、设置css样式
reference : http://www.suyunyou.com/aid1657.html jQuery是继prototype之后又一个优秀的Javascrīpt框架.它是轻量级的js库(压缩后 ...
- spring cloud-给Eureka Server加上安全的用户认证
前言 在前面的一篇文章中 spring cloud中启动Eureka Server 我们启动了Eureka Server,然后在浏览器中输入http://localhost:8761/后,直接回车,就 ...
- EasyUI-Tooltip(提示框)学习
引子: if($("#BLUETOOTH_a")){ $("#BLUETOOTH_a").tooltip({ position: 'right', conten ...
- GeSHi——通用语法高亮显示
Examples Category Examples Views ActionScript 2 46173 Ada 3 27881 Apache configuration 2 40029 Apple ...
- [NPM] Use npx to run commands with different Node.js versions
We will use npx to run a package using different versions of Node.js. This can become valuable when ...
- [Node.js]31. Level 7: Redis coming for Node.js, Simple Redis Commands
Let's start practicing using the redis key-value store from our node application. First require the ...
- [Node.js]25. Level 5. Route params
Create a route that responds to a GET request '/quotes/<name>', then use the param from the UR ...
- 转:Gerrit 学习
转载:http://www.scmeye.com/thread-1665-1-1.html 入门Gerrit简介Gerrit是一个建立在Git版本控制系统之上,基于Web的代码审查工具,但如果你已经阅 ...
- curl_errno错误码说明
http://hi.baidu.com/lifang218c/item/fa80496eb4cf262f68105b50 http://blog.csdn.net/cwj649956781/artic ...