如果仅仅是多个orwhere条件,其实就是默认的andWhere和orWhere的标准写法,但如果条件是:
queue_name != '' and ( queue_status = '' or (queue_status ='error' and retry = 0))这样的要求,用Yii AR 就比较难写了。
demo如下:
PHP代码
- $files = XXXX::find()
- ->andWhere(['<>', 'queue_name', ''])
- ->andWhere(['or',
- ['queue_status' => ''],
- [
- 'and',
- ['queue_status' =>'error'],
- ['retry' => 0]
- ]
- ])
- ->all();
其实也就这样了。。
重点:
1、不等于的写法
2、或条件其实不是用orWhere,而是用andWhere
3、如果orWhere条件中有双重条件,得使用数组,并使用and进行连接
BTW:今天是PHPcon的第一天,然而我却没空去。我是陪读的书童~~~
参考 : http://call-me-early.blogspot.hk/2012/02/tcpdf-chinese-encoding-utf-08-with.html
» 阅读全文
标题对应的代码会报错:Use of undefined constant php - assumed 'php'
果然 有时候还得留个空格啊。万事留一线,日后好相见,说的就是这个道理吧?
原本以为是很简单的一个用法。
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
找了一下原因,在stackoverflow上有很多人提出来。常见的有这两种:在public/index.php里修改最后的$app->run();
- $app->run($app->make('request'));
- $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