diff --git a/src/xPDO/Om/xPDOQuery.php b/src/xPDO/Om/xPDOQuery.php index 72b5001c..cf6d26fa 100644 --- a/src/xPDO/Om/xPDOQuery.php +++ b/src/xPDO/Om/xPDOQuery.php @@ -70,6 +70,7 @@ abstract class xPDOQuery extends xPDOCriteria { protected $_class= null; protected $_alias= null; protected $_tableClass = null; + protected $errors = []; public $graph= array (); public $query= array ( 'command' => 'SELECT', @@ -663,6 +664,10 @@ public function prepare($bindings= array (), $byValue= true, $cacheFlag= null) { } else { $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Could not construct or prepare query because it is invalid or could not connect: ' . $this->sql); } + if (!empty($this->errors)) { + $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, implode("\r\n", $this->errors) . "\r\nQuery: " . $this->sql); + } + return $this->stmt; } @@ -776,7 +781,7 @@ public function parseConditions($conditions, $conjunction = xPDOQuery::SQL_AND) } } if (empty($vals)) { - $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Encountered empty {$operator} condition with key {$key}"); + $this->errors[] = "Encountered empty {$operator} condition with key {$key}."; } $val = "(" . implode(',', $vals) . ")"; $sql = "{$this->xpdo->escape($alias)}.{$this->xpdo->escape($key)} {$operator} {$val}";