original_string: function Save($id, $data = null) {
  		if (!$id)
  			return;
  
  		$this->LoadSchema();
  
  		if (is_array($id)) {
  			$data = $id;
  			if (!isset($data[$this->schema['_id']['field']])) // Incomming data has no ID to address by
  				return;
  			$id = $data[$this->schema['_id']['field']];
  		} else {
  			$data[$this->schema['_id']['field']] = $id;
  		}
  
  		if (!$data)
  			return;
  
  		if ($this->enforceTypes)
  			foreach ($this->schema as $key => $props)
  				if (isset($data[$key]) || $props['type'] == 'json-import')
  					$data[$key] = $this->UnCastType($props['type'], isset($data[$key]) ? $data[$key] : null, $data);
  
  		$this->ResetQuery(array(
  			'method' => 'save',
  			'table' => $this->table,
  			'where' => array(
  				$this->schema['_id']['field'] => $id,
  			),
  			'data' => $data,
  		));
  
  		$this->Trigger('access', $data);
  		if (!$this->continue)
  			return FALSE;
  
  		$this->Trigger('push', $data);
  		if (!$this->continue)
  			return FALSE;
  
  		unset($data[$this->schema['_id']['field']]); // Remove ID from saving data (it will only be removed during filtering anyway as PKs can never be saved)
  
  		$this->trigger('save', $id, $data);
  		if (!$this->continue)
  			return FALSE;
  
  		if (! $data = $this->FilterFields($data, 'set')) // Nothing to save
  			return FALSE;
  		if (!$this->continue)
  			return FALSE;
  
  		$this->db->where("{$this->table}.{$this->schema['_id']['field']}", $id);
  		$this->db->update($this->table, $data);
  
  		$this->Trigger('saved', $id, $save);
  		$this->ClearCache('get', $id); // Wipe the cache so the next get() doesn't return cached data
  
  		return $this->returnRow ? $this->Get($id) : $save;
  	}
code: function Save($id, $data = null) {
  		if (!$id)
  			return;
  
  		$this->LoadSchema();
  
  		if (is_array($id)) {
  			$data = $id;
  			if (!isset($data[$this->schema['_id']['field']])) // Incomming data has no ID to address by
  				return;
  			$id = $data[$this->schema['_id']['field']];
  		} else {
  			$data[$this->schema['_id']['field']] = $id;
  		}
  
  		if (!$data)
  			return;
  
  		if ($this->enforceTypes)
  			foreach ($this->schema as $key => $props)
  				if (isset($data[$key]) || $props['type'] == 'json-import')
  					$data[$key] = $this->UnCastType($props['type'], isset($data[$key]) ? $data[$key] : null, $data);
  
  		$this->ResetQuery(array(
  			'method' => 'save',
  			'table' => $this->table,
  			'where' => array(
  				$this->schema['_id']['field'] => $id,
  			),
  			'data' => $data,
  		));
  
  		$this->Trigger('access', $data);
  		if (!$this->continue)
  			return FALSE;
  
  		$this->Trigger('push', $data);
  		if (!$this->continue)
  			return FALSE;
  
  		unset($data[$this->schema['_id']['field']]); // Remove ID from saving data (it will only be removed during filtering anyway as PKs can never be saved)
  
  		$this->trigger('save', $id, $data);
  		if (!$this->continue)
  			return FALSE;
  
  		if (! $data = $this->FilterFields($data, 'set')) // Nothing to save
  			return FALSE;
  		if (!$this->continue)
  			return FALSE;
  
  		$this->db->where("{$this->table}.{$this->schema['_id']['field']}", $id);
  		$this->db->update($this->table, $data);
  
  		$this->Trigger('saved', $id, $save);
  		$this->ClearCache('get', $id); // Wipe the cache so the next get() doesn't return cached data
  
  		return $this->returnRow ? $this->Get($id) : $save;
  	}
code_tokens: function Save ( $ id , $ data = null ) { if ( ! $ id ) return ; $ this -> LoadSchema ( ) ; if ( is_array ( $ id ) ) { $ data = $ id ; if ( ! isset ( $ data [ $ this -> schema [ '_id' ] [ 'field' ] ] ) ) // Incomming data has no ID to address by return ; $ id = $ data [ $ this -> schema [ '_id' ] [ 'field' ] ] ; } else { $ data [ $ this -> schema [ '_id' ] [ 'field' ] ] = $ id ; } if ( ! $ data ) return ; if ( $ this -> enforceTypes ) foreach ( $ this -> schema as $ key => $ props ) if ( isset ( $ data [ $ key ] ) || $ props [ 'type' ] == 'json-import' ) $ data [ $ key ] = $ this -> UnCastType ( $ props [ 'type' ] , isset ( $ data [ $ key ] ) ? $ data [ $ key ] : null , $ data ) ; $ this -> ResetQuery ( array ( 'method' => 'save' , 'table' => $ this -> table , 'where' => array ( $ this -> schema [ '_id' ] [ 'field' ] => $ id , ) , 'data' => $ data , ) ) ; $ this -> Trigger ( 'access' , $ data ) ; if ( ! $ this -> continue ) return FALSE ; $ this -> Trigger ( 'push' , $ data ) ; if ( ! $ this -> continue ) return FALSE ; unset ( $ data [ $ this -> schema [ '_id' ] [ 'field' ] ] ) ; // Remove ID from saving data (it will only be removed during filtering anyway as PKs can never be saved) $ this -> trigger ( 'save' , $ id , $ data ) ; if ( ! $ this -> continue ) return FALSE ; if ( ! $ data = $ this -> FilterFields ( $ data , 'set' ) ) // Nothing to save return FALSE ; if ( ! $ this -> continue ) return FALSE ; $ this -> db -> where ( "{$this->table}.{$this->schema['_id']['field']}" , $ id ) ; $ this -> db -> update ( $ this -> table , $ data ) ; $ this -> Trigger ( 'saved' , $ id , $ save ) ; $ this -> ClearCache ( 'get' , $ id ) ; // Wipe the cache so the next get() doesn't return cached data return $ this -> returnRow ? $ this -> Get ( $ id ) : $ save ; }
docstring: Attempt to save a database record using the provided data
  Calls the 'save' trigger on the data before it is saved
  @param mixed|array $id The ID to use to identify the record to change or the full row to save (data will be ignored)
  @param array $data A hash of data to attempt to store (optional if ID is the full row)
  @return null|array If $returnRow is true this function will return the newly saved object, if FALSE the array of data saved
docstring_tokens: Attempt to save a database record using the provided data Calls the save trigger on the data before it is saved