Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDbCriteria::addInCondition() return null on non empty array #5

Closed
qiangxue opened this issue Feb 15, 2012 · 0 comments
Closed

CDbCriteria::addInCondition() return null on non empty array #5

qiangxue opened this issue Feb 15, 2012 · 0 comments

Comments

@qiangxue
Copy link
Member

What steps will reproduce the problem?
1.Create a new CDbCriteria
$item = new CdbCriteria;
$Items = $model->findAll($item->addInCondition('id',array(2 => 7)))

What is the expected output? What do you see instead?
in this case $item->addInCondition return 'IS NULL'
findAll return empty array

What version of the product are you using? On what operating system?
Ubuntu 8.04 LTS
lighttpd/1.4.19
PHP Version 5.2.4-2ubuntu5.9
yii-1.0.11
Firefox/3.0.16

Please provide any additional information below.
My patch

public function addInCondition($column,$values,$operator='AND')
{
if(($n=count($values))<1)
return $this->addCondition('0=1',$operator);
if($n===1)
{
+++ $value=array_values($values);
--- if($values[0]===null)
+++ if($value[0]===null)
return $this->addCondition($column.' IS NULL');
$condition=$column.'='.self::PARAM_PREFIX.$this->_paramCount;
--- $this->params[self::PARAM_PREFIX.$this->_paramCount++]=$values[0];
+++ $this->params[self::PARAM_PREFIX.$this->_paramCount++]=$value[0];
}
else
...

Migrated from http://code.google.com/p/yii/issues/detail?id=757


earlier comments

qiang.xue said, at 2010-02-01T21:46:44.000Z:

This issue was closed by revision r1786.

@vaijanath vaijanath mentioned this issue Oct 9, 2013
krushl pushed a commit to krushl1/yii that referenced this issue May 5, 2022
Исправление для передачи параметра when при создании CInlineValidator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant