It defaults to AND; you shouldn’t need that. Although, that statement should still work. Are you sure you have the field names typed right?
[[!Rowboat?
&table=`products`
&tpl=`product_base`
&limit=`10`
&where=`{"a:=":"blah"}`
&sortBy=`pid`
&debug=`1`
]]SELECT * FROM `products` WHERE OR `a` = :a ORDER BY `pid` ASC LIMIT 10
&where=`{"a":"blah"}`Just tried that also:
That’s definitely a bug. Try this:
&where=`{"a":"blah"}`
You don’t need the = unless you’re using a AND/OR conditional.
[[!Rowboat?
&table=`products`
&tpl=`product_base`
&limit=`10`
&where=`{"a":"blah"}`
&sortBy=`pid`
&debug=`1`
]]SELECT * FROM `products` WHERE `a` = :a ORDER BY `pid` ASC LIMIT 10
public function addParam($k,$v) {
if (!empty($v)) {
$kz = explode('.',$k);
$k = !empty($kz[1]) ? $kz[1] : $kz[0];
if (array_key_exists($k,$this->_params)) {
$k = $k.uniqid($k);
}
$this->_params[$k] = $v;
$k = ':'.$k;
} else { $k = '""'; }
return $k;
}$tw[] = $operand.' '.$this->escape($field).' '.$operator.' '.$this->addParam($field,$v);
&where=`{"description:!=":"","OR:name":"Test"}`
&where=`description != '' OR name = 'Test'`
Line 163 rbquery.class.php
public function addParam($k,$v) { if (!empty($v)) { $kz = explode('.',$k); $k = !empty($kz[1]) ? $kz[1] : $kz[0]; if (array_key_exists($k,$this->_params)) { $k = $k.uniqid($k); } $this->_params[$k] = $v; $k = ':'.$k; } else { $k = '""'; } return $k; }
It looks like your addParam function is returning the key with a : in front of it instead of the value. addParam is used in building the where statement:
Line 152 rbquery.class.php
$tw[] = $operand.' '.$this->escape($field).' '.$operator.' '.$this->addParam($field,$v);
Which is producing "WHERE key = :key"
Quote from: thekiller237 at Mar 28, 2011, 04:32 PM
Line 163 rbquery.class.php
public function addParam($k,$v) { if (!empty($v)) { $kz = explode('.',$k); $k = !empty($kz[1]) ? $kz[1] : $kz[0]; if (array_key_exists($k,$this->_params)) { $k = $k.uniqid($k); } $this->_params[$k] = $v; $k = ':'.$k; } else { $k = '""'; } return $k; }
It looks like your addParam function is returning the key with a : in front of it instead of the value. addParam is used in building the where statement:
Line 152 rbquery.class.php
$tw[] = $operand.' '.$this->escape($field).' '.$operator.' '.$this->addParam($field,$v);
Which is producing "WHERE key = :key"
I think the new (:key) "value" is replaced later on by $this->stmt->bindParam(’:’.$k,$v); in the execute function.
It is supposed to replace the :key with the proper value but this does not seem to happen.
I am having some problems with an AND query but i think it comes down to the same trouble as your having.
$this->stmt->bindParam(':'.$k,$v);$this->stmt->bindValue(':'.$k,$v);