手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表分类:PHP

yii2 orwhere andwhere的复杂写法

 如果仅仅是多个orwhere条件,其实就是默认的andWhere和orWhere的标准写法,但如果条件是:

queue_name != '' and ( queue_status = '' or (queue_status ='error' and retry = 0))这样的要求,用Yii AR 就比较难写了。
demo如下:
 
PHP代码
  1. $files = XXXX::find()  
  2.                ->andWhere(['<>''queue_name'''])  
  3.                ->andWhere(['or',  
  4.                    ['queue_status' => ''],  
  5.                    [  
  6.                        'and',  
  7.                        ['queue_status' =>'error'],  
  8.                        ['retry' => 0]  
  9.                    ]  
  10.                ])  
  11.                ->all();  
其实也就这样了。。
重点:
1、不等于的写法
2、或条件其实不是用orWhere,而是用andWhere
3、如果orWhere条件中有双重条件,得使用数组,并使用and进行连接
 
BTW:今天是PHPcon的第一天,然而我却没空去。我是陪读的书童~~~
 

TCPDF - Chinese encoding UTF-08 fonts

参考 : http://call-me-early.blogspot.hk/2012/02/tcpdf-chinese-encoding-utf-08-with.html

 

» 阅读全文

Tags: tcpdf

<?php//test

标题对应的代码会报错:Use of undefined constant php - assumed 'php'

PHP代码
  1. <?php//test  
果然 有时候还得留个空格啊。万事留一线,日后好相见,说的就是这个道理吧?
 
 

Laravel action helper函数用法

原本以为是很简单的一个用法。

action('XxxxController@test',['abc'=>1]);
结果,不仅仅是这样的,
 
如果你的XxxxController@test,没有在router里定义过。会直接报错,报:App\Http\Controller\XxxController@test 不存在,虽然 你很明确的知道它就在那里!
 
原来我 写URL的时候都是直接写 url('abc/def'),其实应该用action('xxxcontroller@def'),好处是,action是可以带参数的。url你永远带不进参数!!!
 
纯记录。NND

Lumen启动时出现:NotFoundHttpException

Lumen在初次安装好启动的时候,访问会出现:NotFoundHttpException

找了一下原因,在stackoverflow上有很多人提出来。常见的有这两种:在public/index.php里修改最后的$app->run();

  1. $app->run($app->make('request'));
  2. $app->run(Illuminate\Http\Request::capture());
如果用第1种,那你会发现所有的路由都被"/"解析了。你随便在URL里输入啥,都只会进入$app->get("/")这个路由
只有第二种才是正确的。
 
记录一下,参考 :
1、http://stackoverflow.com/questions/29728973/notfoundhttpexception-with-lumen
2、http://stackoverflow.com/questions/36436967/just-installed-lumen-and-got-notfoundhttpexception
 

Tags: lumen