summaryrefslogtreecommitdiffstats
path: root/system/database
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2008-02-05 17:03:50 +0100
committerDerek Allard <derek.allard@ellislab.com>2008-02-05 17:03:50 +0100
commit32cf7eb132ec688a3b0339f266efa3f064c58a60 (patch)
treee18b7d714046c2d4f618668286ad9301f82df089 /system/database
parentc27bf007eeaf0fa3e6088e30d6b7ea88b7c0b517 (diff)
Changed the behaviour of Active Record's update() to make the WHERE clause optional (#3395)
Diffstat (limited to 'system/database')
-rw-r--r--system/database/drivers/mssql/mssql_driver.php6
-rw-r--r--system/database/drivers/mysql/mysql_driver.php6
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php6
-rw-r--r--system/database/drivers/oci8/oci8_driver.php6
-rw-r--r--system/database/drivers/odbc/odbc_driver.php6
-rw-r--r--system/database/drivers/postgre/postgre_driver.php6
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php6
7 files changed, 35 insertions, 7 deletions
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index ecd404b52..4cf444088 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -509,7 +509,11 @@ class CI_DB_mssql_driver extends CI_DB {
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ $sql = "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr);
+ $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
+ $sql .= $orderby.$limit;
+
+ return $sql;
}
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index a5082d1b3..372365aeb 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -550,7 +550,11 @@ class CI_DB_mysql_driver extends CI_DB {
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ $sql = "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr);
+ $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
+ $sql .= $orderby.$limit;
+
+ return $sql;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 9e7cc0c9f..31c27117c 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -544,7 +544,11 @@ class CI_DB_mysqli_driver extends CI_DB {
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ $sql = "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr);
+ $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
+ $sql .= $orderby.$limit;
+
+ return $sql;
}
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index aa2aeca42..7aab37e82 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -655,7 +655,11 @@ class CI_DB_oci8_driver extends CI_DB {
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ $sql = "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr);
+ $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
+ $sql .= $orderby.$limit;
+
+ return $sql;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 88fff4365..dd10fbdd3 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -520,7 +520,11 @@ class CI_DB_odbc_driver extends CI_DB {
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ $sql = "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr);
+ $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
+ $sql .= $orderby.$limit;
+
+ return $sql;
}
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index ae8bd86eb..cac0ecb60 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -540,7 +540,11 @@ class CI_DB_postgre_driver extends CI_DB {
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ $sql = "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr);
+ $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
+ $sql .= $orderby.$limit;
+
+ return $sql;
}
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index dad5eeedf..5290edeea 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -536,7 +536,11 @@ class CI_DB_sqlite_driver extends CI_DB {
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ $sql = "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr);
+ $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
+ $sql .= $orderby.$limit;
+
+ return $sql;
}