Ejemplo n.º 1
0
 /**
  * Change one or more values of the unique set assigned to this record.
  * Checks if the record already exists first, if so returns false.
  * If successful returns true and changes $this->unique_set
  * A call to move is instant, it does not require a save() following it.
  */
 function move($new_unique_set)
 {
     // Check if we have a row
     $result = query_single_row('SELECT * FROM ' . prefix($this->table) . getWhereClause($new_unique_set) . ' LIMIT 1;');
     if (!$result || $result['id'] == $this->id) {
         //	we should not find an entry for the new unique set!
         if (!zp_apply_filter('move_object', true, $this, $new_unique_set)) {
             return false;
         }
         $sql = 'UPDATE ' . prefix($this->table) . getSetClause($new_unique_set) . ' ' . getWhereClause($this->unique_set);
         $result = query($sql);
         if ($result && db_affected_rows() == 1) {
             //	and the update should have effected just one record
             $this->unique_set = $new_unique_set;
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Change one or more values of the unique set assigned to this record.
  * Checks if the record already exists first, if so returns false.
  * If successful returns true and changes $this->unique_set
  * A call to move is instant, it does not require a save() following it.
  */
 function move($new_unique_set)
 {
     // Check if we have a row
     $result = query('SELECT * FROM ' . prefix($this->table) . getWhereClause($new_unique_set) . ' LIMIT 1;');
     if (mysql_num_rows($result) == 0) {
         $sql = 'UPDATE ' . prefix($this->table) . getSetClause($new_unique_set) . ' ' . getWhereClause($this->unique_set);
         $result = query($sql);
         if (mysql_affected_rows() == 1) {
             $this->unique_set = $new_unique_set;
             return true;
         }
     }
     return false;
 }