当前位置: 首页 > news >正文

有赞做网站企业推广网

有赞做网站,企业推广网,品牌策划策略,自己做的网站申请软著这篇文章主要介绍了ThinkPHP查询语句与关联查询用法,以实例的形式常见的查询方法,包括数组作为查询条件及对象方式来查询等技巧,需要的朋友可以参考下本文实例讲述了ThinkPHP查询语句与关联查询用法。分享给大家供大家参考。具体如下#xff1a;在thinkphp框架页面中我们可以直…这篇文章主要介绍了ThinkPHP查询语句与关联查询用法,以实例的形式常见的查询方法,包括数组作为查询条件及对象方式来查询等技巧,需要的朋友可以参考下本文实例讲述了ThinkPHP查询语句与关联查询用法。分享给大家供大家参考。具体如下在thinkphp框架页面中我们可以直接拼写sql查询语句来实现数据库查询读写操作下面就对此加以实例说明。普通查询除了字符串查询条件外数组和对象方式的查询条件是非常常用的这些是基本查询所必须掌握的。一、使用数组作为查询条件$User M(User); //实例化User对象$condition[name] thinkphp; // 把查询条件传入查询方法$User-where($condition)-select();二、使用对象方式来查询 可以使用任何对象 这里以stdClass内置对象为例$User M(User); // 实例化User对象// 定义查询条件 $condition new stdClass();$condition-name thinkphp;  // 查询name的值为thinkphp的记录$User-where($condition)-select(); //  上面的查询条件等同于 where(namethinkphp) 使用对象方式查询和使用数组查询的效果是相同的并且是可带where条件的普通查询1、字符串形式$userM(user);$list$user-where(id5 and id9)-select();$list$user-where($data)-select();2、数组形式$userM(user);$list$user-where(array(usernamewww.jb51.net))-select();$list$user-where($data)-select();3、对象形式$userM(user);$anew stdClass();$a-usernamewww.jb51.net;$list$user-where($a)-select();两个表的关联查询$M_shopping M(Shops);$M_product M(Product);$list_shops $M_shopping-join(as shops left join hr_product as product on shops.product_id product.p_id)-field(product.p_id,product.p_name,shops.product_amount,shops.product_id)-where(shops.user_cookie.$_COOKIE[hr_think_userid].)-group(shops.id)-select();区间查询$userM(user);$data[id]array(array(gt,20),array(lt,23),and);$list$user-where($data)-select();组合查询$userM(user);$data[username]pengyanjie;$data[password]array(eq,pengyanjie);$data[id]array(lt,30);$data[_logic]or;$list$user-where($data)-select();dump($list);复合查询$userM(user);$data[username]array(eq,pengyanjie);$data[password]array(like,p%);$data[_logic]or;$where[_complex]$where;$where[id]array(lt,30);$list$user-where($data)-select();三个数据表的关联查询$M_shopping M(Shops);$M_product M(Product);$M_proimg M(Product_image);$list_shops $M_shopping-join(as shops left join hr_product as product on shops.product_id product.p_id left joinhr_product_image as productimgon productimg.p_id product.p_id)-fiel(productimg.pi_url,product.p_id,product.p_name,shops.product_amount,shops.product_id,product.am_id,product.p_procolor,product.p_price,product_amount*p_price as totalone)-where(shops.user_cookie.$_COOKIE[hr_think_userid].)-group(shops.id)-select();数据表的查询条件① 下面的是直接吧查询的条件放到了where中这样就方便了条件的书写$m_test M(Product);$productmeaage $m_test-where(p_id$proid)-select();② 除了上面的方法还有一种是以数组的方式$M_product M(Product);$map[pid] $proid;$p_result $M_product-where($map)-select();希望本文所述对大家的ThinkPHP框架程序设计有所帮助。
http://www.zqtcl.cn/news/261826/

相关文章:

  • 做地方网站如何盈利电脑上怎样进入中国建设银行网站
  • 网站建设初期问题常见wordpress 3.8页面伪静态化 html
  • wordpress字不能显示嘉兴优化网站公司
  • 免费行情网站大全下载wordpress访问要10多秒
  • 内蒙古生产建设兵团四师三十四团知青网站绵阳哪里可以做网站的地方
  • 网站建设找推推蛙wordpress 评论 字段
  • 河北保定网站建设石家庄网站建设找汉狮
  • 网站建设风险分析网站开发需多少钱
  • 苏州企业网站制作程序开发的步骤
  • 网站开发与维护竞赛深圳建设局官网站
  • 开发网站的费用属于什么费用高等院校网站建设方案
  • 建设化工网站的功能百度装修网站
  • 重庆大渡口营销型网站建设价格网站404 原因
  • 网网站建设公司咨询php asp jsp 网站
  • 遂宁北京网站建设微盟微商城官网
  • 惠州网站建设创业三明百度seo
  • 网站制作模板公司网站维护流程
  • 超炫网站模板友情链接交换教程
  • 物流公司做网站有用吗备案网站的黑名单
  • 多语言网站制作长沙市做网站的
  • 做视频点播网站要多少带宽怎么用电脑做网站服务器吗
  • 新办公司网上核名在哪个网站做网站内容作弊的形式
  • 网站风格化设计方案常见的erp软件有哪些
  • 河北石家庄特产做网站优化的
  • 做网站工资年新多少在广东番禺网页设计公司
  • 宝安专业手机网站设计公司王野天个人资料
  • 给网站做蜘蛛抓取赚钱
  • 康保网站制作高端网站制作服务
  • 网站建设的网站分析怎么写crm管理系统销售
  • 茂名做网站的公司大专学电子商务有用吗