Skip to content
Browse files

Globalize freeze (moved to NotORM)

  • Loading branch information...
1 parent efd6ff0 commit 97201149949d7ae887430ecaf83e46d1f584e427 @vrana committed Sep 23, 2010
Showing with 18 additions and 20 deletions.
  1. +15 −3 NotORM.php
  2. +3 −11 NotORM/Result.php
  3. +0 −6 NotORM/Row.php
View
18 NotORM.php
@@ -16,7 +16,12 @@
// friend visibility emulation
abstract class NotORM_Abstract {
protected $connection, $structure, $cache;
- protected $notORM, $table, $primary, $rows, $referenced = array(), $freeze = false;
+ protected $notORM, $table, $primary, $rows, $referenced = array();
+
+ /** Disable persistence
+ * @access public write-only
+ */
+ protected $freeze = false;
abstract protected function __construct();
@@ -50,8 +55,15 @@ function __construct(PDO $connection, NotORM_Structure $structure = null, NotORM
function __get($table) {
return new NotORM_Result($table, $this, true);
}
-
- // __set is not defined to allow storing custom result sets (undocumented)
+
+ /** Set write-only properties
+ * @return null
+ */
+ function __set($name, $value) {
+ if ($name == "freeze") {
+ $this->$name = $value;
+ }
+ }
/** Get table data
* @param string
View
14 NotORM/Result.php
@@ -85,20 +85,12 @@ protected function quote($val) {
));
}
- /** Disable persistence
- * @return NotORM_Result fluent interface
- */
- function freeze() {
- $this->freeze = true;
- return $this;
- }
-
/** Insert row in a table
* @param mixed array($column => $value)|Traversable for single row insert or NotORM_Result|string for INSERT ... SELECT
* @return string auto increment value or false in case of an error
*/
function insert($data) {
- if ($this->freeze) {
+ if ($this->notORM->freeze) {
return false;
}
if ($data instanceof NotORM_Result) {
@@ -122,7 +114,7 @@ function insert($data) {
* @return int number of affected rows or false in case of an error
*/
function update(array $data) {
- if ($this->freeze) {
+ if ($this->notORM->freeze) {
return false;
}
if (!$data) {
@@ -144,7 +136,7 @@ function update(array $data) {
* @return int number of affected rows or false in case of an error
*/
function delete() {
- if ($this->freeze) {
+ if ($this->notORM->freeze) {
return false;
}
$return = $this->query("DELETE" . $this->topString() . " FROM $this->table" . $this->whereString());
View
6 NotORM/Row.php
@@ -32,9 +32,6 @@ function __get($name) {
}
$referenced = new NotORM_Result($table, $this->result->notORM);
$referenced->where($this->result->notORM->structure->getPrimary($table), array_keys($keys));
- if ($this->result->freeze) {
- $referenced->freeze();
- }
}
if (!isset($referenced[$this[$column]])) { // referenced row may not exist
return null;
@@ -65,9 +62,6 @@ function __call($name, array $args) {
if ($args) {
call_user_func_array(array($return, 'where'), $args);
}
- if ($this->result->freeze) {
- $return->freeze();
- }
return $return;
}

0 comments on commit 9720114

Please sign in to comment.
Something went wrong with that request. Please try again.