summaryrefslogtreecommitdiff
path: root/idiorm.php
diff options
context:
space:
mode:
authorJamie Matthews <[email protected]>2010-10-25 13:59:39 +0100
committerJamie Matthews <[email protected]>2010-10-25 13:59:39 +0100
commit0d61bbbfca8df2c3212abbc701b21ec90439b58b (patch)
tree2c8a95f7740fb1e877ffb4d83dfe3062a548b1c6 /idiorm.php
parent2a4ed42e4642ff21434c64bb5082406c4e3d516c (diff)
Remove _update_or_insert, this is now tracked by testing whether id() returns null
Diffstat (limited to 'idiorm.php')
-rw-r--r--idiorm.php14
1 files changed, 2 insertions, 12 deletions
diff --git a/idiorm.php b/idiorm.php
index 86fbd1b..20e3ead 100644
--- a/idiorm.php
+++ b/idiorm.php
@@ -44,10 +44,6 @@
// --- CLASS CONSTANTS --- //
// ----------------------- //
- // Update or insert?
- const UPDATE = 0;
- const INSERT = 1;
-
// Where condition array keys
const WHERE_FRAGMENT = 0;
const WHERE_VALUES = 1;
@@ -121,9 +117,6 @@
// lifetime of the object
protected $_dirty_fields = array();
- // Are we updating or inserting?
- protected $_update_or_insert = self::UPDATE;
-
// Name of the column to use as the primary key for
// this instance only. Overrides the config settings.
protected $_instance_id_column = null;
@@ -266,8 +259,6 @@
* save() is called.
*/
public function create($data=null) {
- $this->_update_or_insert = self::INSERT;
-
if (!is_null($data)) {
return $this->hydrate($data)->force_all_dirty();
}
@@ -742,7 +733,7 @@
$query = array();
$values = array_values($this->_dirty_fields);
- if ($this->_update_or_insert == self::UPDATE) {
+ if (!is_null($this->id())) { // UPDATE
// If there are no dirty values, do nothing
if (count($values) == 0) {
return true;
@@ -759,8 +750,7 @@
$success = $statement->execute($values);
// If we've just inserted a new record, set the ID of this object
- if ($this->_update_or_insert == self::INSERT) {
- $this->_update_or_insert = self::UPDATE;
+ if (is_null($this->id())) {
$this->_data[$this->_get_id_column_name()] = self::$_db->lastInsertId();
}