Skip to content

Commit 5622f2f

Browse files
author
Raphaël BERGINA
committed
Fix Parameters with IN condition
1 parent 0b8d5a6 commit 5622f2f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/SQLParser/Node/Parameter.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,25 @@ public function toSql(array $parameters = array(), Connection $dbConnection = nu
155155
{
156156
if (isset($parameters[$this->name])) {
157157
if ($dbConnection) {
158-
return $dbConnection->quote($this->autoPrepend.$parameters[$this->name].$this->autoAppend);
158+
if(is_array($parameters[$this->name])){
159+
return '('.implode(',',array_map(function($item) use ($dbConnection) {
160+
return $dbConnection->quote($this->autoPrepend.$item.$this->autoAppend);
161+
}, $parameters[$this->name])).')';
162+
} else{
163+
return $dbConnection->quote($this->autoPrepend.$parameters[$this->name].$this->autoAppend);
164+
}
159165
} else {
160166
if ($parameters[$this->name] === null) {
161-
return null;
167+
return "null";
162168
} else {
163-
return "'".addslashes($this->autoPrepend.$parameters[$this->name].$this->autoAppend)."'";
169+
if(is_array($parameters[$this->name])){
170+
return '('.implode(',',array_map(function($item) {
171+
return addslashes($this->autoPrepend.$item.$this->autoAppend);
172+
}, $parameters[$this->name])).')';
173+
} else{
174+
return "'".addslashes($this->autoPrepend.$parameters[$this->name].$this->autoAppend)."'";
175+
}
176+
164177
}
165178
}
166179
} else {

0 commit comments

Comments
 (0)