Skip to content

Commit ac7ad1c

Browse files
author
Drak
committed
Merge pull request #24 from SlikNL/warn-about-joins-on-non-selects
Warn if trying to join UPDATE or DELETE queries
2 parents c3b8a2b + 2e2e37a commit ac7ad1c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/Doctrine/Query/Abstract.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,8 @@ public function from($from)
16601660
*/
16611661
public function innerJoin($join, $params = array())
16621662
{
1663+
$this->checkIfCanJoin();
1664+
16631665
if (is_array($params)) {
16641666
$this->_params['join'] = array_merge($this->_params['join'], $params);
16651667
} else {
@@ -1678,6 +1680,8 @@ public function innerJoin($join, $params = array())
16781680
*/
16791681
public function leftJoin($join, $params = array())
16801682
{
1683+
$this->checkIfCanJoin();
1684+
16811685
if (is_array($params)) {
16821686
$this->_params['join'] = array_merge($this->_params['join'], $params);
16831687
} else {
@@ -2177,4 +2181,17 @@ public function setDisableLimitSubquery($disableLimitSubquery)
21772181
{
21782182
$this->disableLimitSubquery = $disableLimitSubquery;
21792183
}
2184+
2185+
private function checkIfCanJoin()
2186+
{
2187+
// Joins in Updates and Deletes are not SQL standard,
2188+
// Doctrine does not support them even on supporting databases:
2189+
// http://www.doctrine-project.org/jira/browse/DC-202
2190+
if ($this->getType() !== self::SELECT) {
2191+
trigger_error(
2192+
'Joins are only supported with SELECTs',
2193+
E_USER_DEPRECATED
2194+
);
2195+
}
2196+
}
21802197
}

0 commit comments

Comments
 (0)