Maison  >  Article  >  développement back-end  >  thinkphp like 查询_PHP教程

thinkphp like 查询_PHP教程

WBOY
WBOYoriginal
2016-07-13 10:31:151156parcourir

在做项目的过程中,需要用到like关键字来组合查询条件,下面作者将在thinkphp中使用到的 like 查询做一下分享。

这里主要通过举例来说明用法:

$userForm=M('user');
$where['name']=array('like','phpernote%');
$userForm->where($where)->select();

这里的like查询即为:name like 'phpernote%'

$where['name']=array('like',array('%phpernote%','%.com'),'OR');

这里的like查询即为:name like '%phpernote%' or name like '%.com'

$where['name']=array(array('like','%a%'),array('like','%b%'),array('like','%c%'),'phpernote','or');

这里的like查询即为:(`name` LIKE '%a%') OR (`name` LIKE '%b%') OR (`name` LIKE '%c%') OR (`name` = 'phpernote')

$where['_string']='(name like "%phpernote%")  OR (title like "%phpernote")';

这里的like查询即为:name like '%phpernote%' or title like '%phpernote'

您可能感兴趣的文章

  • ThinkPHP中的查询技巧总结
  • thinkphp 的 Action 控制器中的系统常量总结
  • thinkphp 如何去除url中的index.php
  • thinkphp模板中判断volist循环的最后一条记录
  • thinkphp打印最后一条sql语句
  • Thinkphp 模板中常用的系统变量总结
  • 使用ThinkPHP必须掌握的调试方法
  • Thinkphp 内部函数 ADSLCFUI 快捷方法全解析

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/764119.htmlTechArticle在做项目的过程中,需要用到like关键字来组合查询条件,下面作者将在thinkphp中使用到的 like 查询做一下分享。 这里主要通过举例来说明用...
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn