Record Class Reference

List of all members.

Public Member Functions

 __construct (DataSet $ds, $addRecord=false)
 Creates a new Record and sets the parent dataset to the passed in value.
 delete (Connection $conn=null)
 Shortcut method to delete this record.
 save (Connection $conn=null)
 Saves the data in this Record to the database.
 getValue ($col)
 Gets the value for specified column.
 columns ()
 Get the column names for current record.
 size ()
 The number of columns in this object.
 toBeSavedWithInsert ()
 Whether or not this Record is to be saved with an SQL insert statement.
 toBeSavedWithUpdate ()
 Whether or not this Record is to be saved with an SQL update statement.
 toBeSavedWithDelete ()
 Whether or not this Record is to be saved with an SQL delete statement.
 markRecordClean ()
 Marks all the values in this record as clean.
 markForInsert ()
 Marks this record to be inserted when a save is executed.
 markForUpdate ()
 Marks this record to be updated when a save is executed.
 markToBeDeleted ()
 Marks this record to be deleted when a save is executed.
 unmarkToBeDeleted ()
 Unmarks a record that has been marked for deletion.
 markValueClean ($col)
 Marks a value with a given column name as clean (unmodified).
 markValueDirty ($col)
 Marks a value with a given column as "dirty" (modified).
 setSaveType ($type)
 Sets the internal save type as one of the defined privates (ie: ZOMBIE).
 getSaveType ()
 Gets the internal save type as one of the defined privates (ie: ZOMBIE).
 setValue ($col, $value)
 Sets the value of col.
 isAZombie ()
 Determines if this record is a Zombie.
 needsToBeSaved ()
 If the record is not clean, needs to be saved with an Update, Delete or Insert, it returns true.
 valueIsClean ($column)
 Determines whether or not a value stored in the record is clean.
 recordIsClean ()
 Goes through all the values in the record to determine if it is clean or not.
 refresh (Connection $conn=null)
 This method refreshes this Record's Value's.
 getRefreshSql ()
 This builds the SELECT statement in order to refresh the contents of this Record.
 dataset ()
 Gets the DataSet for this Record.
 setParentDataSet (DataSet $ds)
 Sets the parent DataSet for this record.
 __toString ()
 This returns a representation of this Record.

Public Attributes

const ZOMBIE = -1
const UNKNOWN = 0
const INSERT = 1
const UPDATE = 2
const DELETE = 3
const BEFOREINSERT = 4
const AFTERINSERT = 5
const BEFOREUPDATE = 6
const AFTERUPDATE = 7
const BEFOREDELETE = 8
const AFTERDELETE = 9

Private Member Functions

 initializeRecord ()
 Performs initialization for this Record.
 createValues (ResultSet $rs)
 Creates the value objects for this Record.
 doDelete (Connection $conn=null)
 Performs a DELETE on databse using this Record as criteria.
 doUpdate (Connection $conn=null)
 Saves the data in this Record to the database with an UPDATE statement.
 doInsert (Connection $conn=null)
 Saves the data in this Record to the database with an INSERT statement.
 getUpdateSql ()
 Builds the SQL UPDATE statement for this Record.
 getDeleteSql ()
 Builds the SQL DELETE statement for this Record.
 getInsertSql ()
 Builds the SQL INSERT statement for this Record.
 dirtyColumns ()
 Get the modified (dirty) columns.

Private Attributes

 $values = array()
 an array of values strings, indexed by column name.
 $dirtyCols = array()
 array of modified (dirty) columns
 $ds
 the parent DataSet for this Record
 $saveType = 0
 this is the state of this record


Detailed Description

Definition at line 41 of file Record.php.


Constructor & Destructor Documentation

Record::__construct ( DataSet ds,
addRecord = false 
)

Creates a new Record and sets the parent dataset to the passed in value.

If $addRecord is true, then an empty record is created.

Parameters:
DataSet $ds The parent / owning dataset.
boolean $addRecord Whether to create an empty record.

Definition at line 76 of file Record.php.

References createValues(), and setParentDataSet().

00077     {
00078         $this->setParentDataSet($ds);
00079         if (!$addRecord) {        
00080             $this->createValues($this->ds->resultSet());
00081         }
00082     }


Member Function Documentation

Record::__toString (  ) 

This returns a representation of this Record.

Returns:
string

Definition at line 732 of file Record.php.

References columns(), and getValue().

00733     {
00734         $sb = "{";
00735         foreach($this->columns() as $col) {
00736             $sb .= "'" . $this->getValue($col) . "',";
00737         }
00738         $sb = substr($sb, 0, -1);
00739         $sb .= "}";
00740         return $sb;
00741     }

Record::columns (  ) 

Get the column names for current record.

Returns:
array Column names.

Definition at line 398 of file Record.php.

Referenced by __toString(), and getRefreshSql().

00399     {
00400         return array_keys($this->values);
00401     }

Record::createValues ( ResultSet rs  )  [private]

Creates the value objects for this Record.

It is 1 based

Returns:
void

Definition at line 99 of file Record.php.

References ResultSet::getRow().

Referenced by __construct(), and refresh().

00100     {
00101         $this->values = $rs->getRow();
00102     }

Record::dataset (  ) 

Gets the DataSet for this Record.

Returns:
DataSet

Definition at line 714 of file Record.php.

00715     {
00716         return $this->ds;
00717     }

Record::delete ( Connection conn = null  ) 

Shortcut method to delete this record.

Parameters:
Connection $conn

Definition at line 108 of file Record.php.

References DELETE, save(), and setSaveType().

00109     {
00110         $this->setSaveType(DELETE);
00111         $this->save($conn);
00112     }

Record::dirtyColumns (  )  [private]

Get the modified (dirty) columns.

Private right now because this is only used internally. No real reason why this couldn't be public, though ...

Returns:
array

Definition at line 409 of file Record.php.

Referenced by doInsert(), doUpdate(), getInsertSql(), and getUpdateSql().

00410     {
00411         return array_keys($this->dirtyCols);
00412     }

Record::doDelete ( Connection conn = null  )  [private]

Performs a DELETE on databse using this Record as criteria.

Returns:
int Number of rows affected by delete.
Exceptions:
DataSetException,SQLException 

Definition at line 154 of file Record.php.

References CreoleTypes::getAffix(), getDeleteSql(), getValue(), setSaveType(), and ZOMBIE.

Referenced by save().

00155     {
00156         if ($conn === null) {
00157             $conn = $this->ds->connection();
00158         }
00159         
00160         $table = $this->ds->tableInfo();
00161         $stmt = null;
00162         try {
00163             $stmt = $conn->prepareStatement($this->getDeleteSql());
00164             $ps = 1;
00165             $kd = $this->ds->keydef();
00166             for ($i = 1, $kdsize = $kd->size(); $i <= $kdsize; $i++) {                
00167                 $col = $kd->getAttrib($i);
00168                 $val = $this->getValue($col);                    
00169                 $setter = 'set' . CreoleTypes::getAffix( $table->getColumn($col)->getType() );
00170                 $stmt->$setter($ps++, $val);
00171             }
00172 
00173             $ret = $stmt->executeUpdate();
00174 
00175             // note that the actual removal of the Record objects 
00176             // from the DataSet is done by the TDS::save() method.
00177             $this->setSaveType(Record::ZOMBIE);
00178             
00179             $stmt->close();
00180             
00181             if ($ret > 1) {
00182                 throw new SQLException("There were " . $ret . " rows deleted with this records key value.");
00183             }
00184             
00185             return $ret;
00186             
00187         } catch (SQLException $e) {
00188             if ($stmt) $stmt->close();
00189             throw $e;
00190         }
00191     }

Record::doInsert ( Connection conn = null  )  [private]

Saves the data in this Record to the database with an INSERT statement.

Returns:
int
Exceptions:
DataSetException,SQLException 

Definition at line 250 of file Record.php.

References AFTERINSERT, dirtyColumns(), CreoleTypes::getAffix(), getInsertSql(), getValue(), markRecordClean(), refresh(), and setSaveType().

Referenced by save().

00251     {
00252         $stmt = null;
00253 
00254         try {
00255             $stmt = $conn->prepareStatement($this->getInsertSql());
00256             $ps = 1;
00257             foreach($this->dirtyColumns() as $col) {
00258                 $val = $this->getValue($col);
00259                 $setter = 'set' . CreoleTypes::getAffix( $table->getColumn($col)->getType() );
00260                 $stmt->$setter($ps++, $val);
00261             }
00262             
00263             $ret = $stmt->executeUpdate();
00264 
00265             if ($this->ds->refreshOnSave()) {
00266                 $this->refresh();
00267             } else {
00268                 // Marks all of the values clean since they have now been saved
00269                 $this->markRecordClean();
00270             }
00271 
00272             $this->setSaveType(Record::AFTERINSERT);
00273 
00274             if ($ret > 1) {
00275                 // a little late again...
00276                 throw new SQLException ("There were " . $ret . " rows inserted with this records key value.");
00277             }
00278 
00279             return $ret;
00280         } catch (SQLException $e) {
00281             if ($stmt) $stmt->close();
00282             throw $e;
00283         }        
00284     }

Record::doUpdate ( Connection conn = null  )  [private]

Saves the data in this Record to the database with an UPDATE statement.

Returns:
SQL UPDATE statement
Exceptions:
DataSetException,SQLException 

Definition at line 198 of file Record.php.

References AFTERUPDATE, dirtyColumns(), CreoleTypes::getAffix(), getUpdateSql(), getValue(), markRecordClean(), refresh(), and setSaveType().

Referenced by save().

00199     {
00200         if ($conn === null) {
00201             $conn = $this->ds->connection();
00202         }
00203         
00204         $table = $this->ds->tableInfo();
00205         
00206         $stmt = null;
00207         try {
00208             $stmt = $conn->prepareStatement($this->getUpdateSql());
00209             
00210             $ps = 1;
00211             foreach($this->dirtyColumns() as $col) {
00212                 $setter = 'set' . CreoleTypes::getAffix( $table->getColumn($col)->getType() );
00213                 $stmt->$setter($ps++, $this->getValue($col));
00214             }
00215 
00216             $kd = $this->ds->keydef();
00217             for ($i = 1, $kdsize = $kd->size(); $i <= $kdsize; $i++) {
00218                 $attrib = $kd->getAttrib($i);
00219                 $setter = 'set' . CreoleTypes::getAffix( $table->getColumn($attrib)->getType() );
00220                 $stmt->$setter($ps++, $this->getValue($attrib));
00221             }
00222             
00223             $ret = $stmt->executeUpdate();
00224 
00225             if ($this->ds->refreshOnSave()) {
00226                 $this->refresh();
00227             } else {
00228                 // Marks all of the values clean since they have now been saved
00229                 $this->markRecordClean();
00230             }
00231 
00232             $this->setSaveType(Record::AFTERUPDATE);
00233 
00234             if ($ret > 1) {
00235                 throw new SQLException ("There were " . $ret . " rows updated with this records key value.");
00236             }            
00237             return $ret;
00238         } catch (SQLException $e) {
00239             if ($stmt) $stmt->close();
00240             throw $e;
00241         }
00242         
00243     }

Record::getDeleteSql (  )  [private]

Builds the SQL DELETE statement for this Record.

Returns:
string SQL DELETE statement
Exceptions:
DataSetException - if no keydef

Definition at line 336 of file Record.php.

Referenced by doDelete().

00337     {
00338         $kd = $this->ds->keydef();
00339         
00340         if ($kd === null || $kd->size() === 0) {
00341             throw new DataSetException("You must specify KeyDef attributes for this TableDataSet in order to delete a Record.");
00342         }
00343 
00344         $where_sql = "";
00345         $comma = false;
00346         for ($i = 1, $kdsize = $kd->size(); $i <= $kdsize; $i++) {
00347             if (!$comma) {
00348                 $where_sql .= $kd->getAttrib($i) . " = ?";               
00349                 $comma = true;
00350             } else {
00351                 $where_sql .= " AND " . $kd->getAttrib($i) . " = ?";
00352             }
00353         }
00354         
00355         return "DELETE FROM " . $this->ds->tableName() . " WHERE " . $where_sql;
00356     }

Record::getInsertSql (  )  [private]

Builds the SQL INSERT statement for this Record.

Returns:
string SQL INSERT statement

Definition at line 362 of file Record.php.

References dirtyColumns().

Referenced by doInsert().

00363     {
00364         $fields_sql = "";
00365         $values_sql = "";                
00366         $comma = false;
00367         foreach($this->dirtyColumns() as $col) {
00368             if (!$comma) {
00369                 $fields_sql .= $col;
00370                 $values_sql .= "?";
00371                 $comma = true;
00372             } else {
00373                 $fields_sql .= ", " . $col;                    
00374                 $values_sql .= ", ?";
00375             }
00376         }
00377         return "INSERT INTO " . $this->ds->tableName() . " ( " . $fields_sql . " ) VALUES ( " . $values_sql . " )";
00378     }       

Record::getRefreshSql (  ) 

This builds the SELECT statement in order to refresh the contents of this Record.

It depends on a valid KeyDef to exist and it must have been created with a TableDataSet.

Returns:
string The SELECT SQL
Exceptions:
DataSetException 

Definition at line 666 of file Record.php.

References columns(), and valueIsClean().

Referenced by refresh().

00667     {
00668         if ($this->ds->keydef() === null || $this->ds->keydef()->size() === 0) {
00669             throw new DataSetException("You can only perform a getRefreshQueryString on a TableDataSet that was created with a KeyDef.");            
00670         } elseif ($this->ds instanceof QueryDataSet) {
00671             throw new DataSetException("You can only perform a getRefreshQueryString on Records created with a TableDataSet.");
00672         }
00673         
00674         $sql1 = "";
00675         $sql2 = "";
00676         $comma = false;
00677 
00678         foreach($this->columns() as $col) {
00679             if (!$comma) {                
00680                 $attribs_sql .= $col;
00681                 $comma = true;
00682             } else {
00683                 $attribs_sql .= ", " . $col;
00684             }
00685         }
00686 
00687         $comma = false;
00688 
00689         for ($i = 1, $kdsize = $kd->size(); $i <= $kdsize; $i++) {
00690             $attrib = $kd->getAttrib($i);
00691 
00692             if (!$this->valueIsClean($attrib)) {
00693                 throw new DataSetException (
00694                         "You cannot do a refresh from the database if the value " .
00695                         "for a KeyDef column has been changed with a Record.setValue().");
00696             }
00697             
00698             if (!$comma) {
00699                 $where_sql .= $attrib . " = ?";
00700                 $comma = true;
00701             } else {
00702                 $where_sql .= " AND " . $attrib . " = ?";
00703             }
00704         }
00705         
00706         return "SELECT " . $attribs_sql . " FROM " . $this->ds->tableName() . " WHERE " . $where_sql;
00707     }    

Record::getSaveType (  ) 

Gets the internal save type as one of the defined privates (ie: ZOMBIE).

Returns:
int

Definition at line 551 of file Record.php.

00552     {
00553         return $this->saveType;    
00554     }

Record::getUpdateSql (  )  [private]

Builds the SQL UPDATE statement for this Record.

Returns:
string SQL UPDATE statement
Exceptions:
DataSetException 

Definition at line 291 of file Record.php.

References dirtyColumns(), recordIsClean(), and valueIsClean().

Referenced by doUpdate().

00292     {
00293         $kd = $this->ds->keydef();
00294         if ($kd === null || $kd->size() === 0) {
00295             throw new DataSetException("You must specify KeyDef attributes for this TableDataSet in order to create a Record for update.");
00296         } elseif ($this->recordIsClean()) {
00297             throw new DataSetException ("You must Record->setValue() on a column before doing an update.");
00298         }
00299 
00300         $set_sql = "";
00301         $where_sql = "";
00302         
00303         $comma = false;
00304         
00305         foreach($this->dirtyColumns() as $col)  {
00306             if (!$comma) {
00307                 $set_sql .= $col . " = ?";
00308                 $comma = true;
00309             } else {
00310                 $set_sql .= ", " . $col . " = ?";
00311             }            
00312         }
00313 
00314         $comma = false;               
00315         for ($i = 1, $kdsize = $kd->size(); $i <= $kdsize; $i++) {        
00316             $attrib = $kd->getAttrib($i);
00317             if (! $this->valueIsClean ($attrib)) {
00318                 throw new DataSetException ("The value for column '" . $attrib . "' is a key value and cannot be updated.");
00319             }
00320             if (!$comma) {
00321                 $where_sql .= $attrib . " = ?";
00322                 $comma = true;
00323             } else {
00324                 $where_sql .= " AND " . $attrib . " = ?";
00325             }
00326         }
00327         return "UPDATE " . $this->ds->tableName() . " SET " . $set_sql . " WHERE " . $where_sql;
00328     }    

Record::getValue ( col  ) 

Gets the value for specified column.

This function performs no type-conversion.

Returns:
string The value object for specified column as string.
Exceptions:
DataSetException 

Definition at line 386 of file Record.php.

Referenced by __toString(), doDelete(), doInsert(), doUpdate(), and refresh().

00387     {
00388         if (!isset($this->values[$col])) {
00389             throw new DataSetException("Undefined column in Record: " . $col);
00390         }        
00391         return $this->values[$col];
00392     }   

Record::initializeRecord (  )  [private]

Performs initialization for this Record.

Definition at line 87 of file Record.php.

References setSaveType(), and UNKNOWN.

Referenced by refresh().

00088     {
00089         $this->values = array();
00090         $this->dirtyCols = array();
00091         $this->setSaveType(Record::UNKNOWN);                
00092     }

Record::isAZombie (  ) 

Determines if this record is a Zombie.

A Zombie is a record that has been deleted from the database, but not yet removed from the DataSet.

Returns:
boolean

Definition at line 574 of file Record.php.

References ZOMBIE.

Referenced by needsToBeSaved().

00575     {
00576         return ($this->saveType === Record::ZOMBIE);
00577     }

Record::markForInsert (  ) 

Marks this record to be inserted when a save is executed.

Returns:
void
Exceptions:
DataSetException - if DataSet is not TableDataSet

Definition at line 464 of file Record.php.

References INSERT, and setSaveType().

00465     {
00466         if ($this->ds instanceof QueryDataSet) {
00467             throw new DataSetException ("You cannot mark a record in a QueryDataSet for insert");
00468         }
00469         $this->setSaveType(Record::INSERT);
00470     }

Record::markForUpdate (  ) 

Marks this record to be updated when a save is executed.

Returns:
void
Exceptions:
DataSetException - if DataSet is not TableDataSet

Definition at line 477 of file Record.php.

References setSaveType(), and UPDATE.

00478     {
00479         if ($this->ds instanceof QueryDataSet) {
00480             throw new DataSetException ("You cannot mark a record in a QueryDataSet for update");
00481         }
00482         $this->setSaveType(Record::UPDATE);
00483     }

Record::markRecordClean (  ) 

Marks all the values in this record as clean.

Returns:
void

Definition at line 454 of file Record.php.

Referenced by doInsert(), and doUpdate().

00455     {
00456         $this->dirtyCols = array();
00457     }

Record::markToBeDeleted (  ) 

Marks this record to be deleted when a save is executed.

Returns:
void
Exceptions:
DataSetException - if DataSet is not TableDataSet

Definition at line 489 of file Record.php.

References DELETE, and setSaveType().

00490     {
00491         if ($this->ds instanceof QueryDataSet) {
00492             throw new DataSetException ("You cannot mark a record in a QueryDataSet for deletion");
00493         }
00494         $this->setSaveType(Record::DELETE);
00495         // return this;
00496     }

Record::markValueClean ( col  ) 

Marks a value with a given column name as clean (unmodified).

Parameters:
string $col
Returns:
void

Definition at line 522 of file Record.php.

00523     {
00524         unset($this->dirtyCols[$col]);
00525     }

Record::markValueDirty ( col  ) 

Marks a value with a given column as "dirty" (modified).

Parameters:
string $col
Returns:
void

Definition at line 532 of file Record.php.

Referenced by setValue().

00533     {
00534         $this->dirtyCols[$col] = true;
00535     }

Record::needsToBeSaved (  ) 

If the record is not clean, needs to be saved with an Update, Delete or Insert, it returns true.

Returns:
boolean

Definition at line 583 of file Record.php.

References isAZombie(), recordIsClean(), toBeSavedWithDelete(), toBeSavedWithInsert(), and toBeSavedWithUpdate().

Referenced by save().

00584     {
00585         return (!$this->isAZombie() || !$this->recordIsClean() || $this->toBeSavedWithUpdate() ||
00586                 $this->toBeSavedWithDelete() || $this->toBeSavedWithInsert());
00587     }

Record::recordIsClean (  ) 

Goes through all the values in the record to determine if it is clean or not.

Returns:
true if clean

Definition at line 606 of file Record.php.

Referenced by getUpdateSql(), and needsToBeSaved().

00607     {
00608         return empty($this->dirtyCols);
00609     }

Record::refresh ( Connection conn = null  ) 

This method refreshes this Record's Value's.

It can only be performed on a Record that has not been modified and has been created with a TableDataSet and corresponding KeyDef.

Parameters:
Connection $conn
Exceptions:
DataSetException 
SQLException 

Definition at line 620 of file Record.php.

References createValues(), CreoleTypes::getAffix(), getRefreshSql(), getValue(), initializeRecord(), toBeSavedWithDelete(), and toBeSavedWithInsert().

Referenced by doInsert(), and doUpdate().

00621     {
00622         if ($conn === null) {
00623             $conn = $this->ds->connection();
00624         }
00625         
00626         if ($this->toBeSavedWithDelete()) {
00627             return;
00628         } elseif ($this->toBeSavedWithInsert()) {
00629             throw new DataSetException("There is no way to refresh a record which has been created with addRecord().");
00630         } elseif ($this->ds instanceof QueryDataSet) {
00631             throw new DataSetException ("You can only perform a refresh on Records created with a TableDataSet.");
00632         }
00633 
00634         $stmt = null;
00635         try {        
00636             $stmt = $conn->prepareStatement ($this->getRefreshSql());
00637             $ps = 1;
00638             $kd = $this->ds->keydef();
00639             for ($i = 1, $kdsize = $kd->size(); $i <= $kdsize; $i++)
00640             {
00641                 $val = $this->getValue($kd->getAttrib($i));
00642                 if ($val == null) {
00643                     throw new DataSetException ("You cannot execute an update with a null value for a KeyDef.");
00644                 }                    
00645                 $setter = 'set' . CreoleTypes::getAffix( $table->getColumn($col)->getType() );
00646                 $stmt->$setter($ps++, $val);
00647             }
00648             $rs = $stmt->executeQuery();
00649             $rs->next();            
00650             $this->initializeRecord();
00651             $this->createValues($rs);
00652         } catch (SQLException $e) {
00653             if ($stmt) $stmt->close();
00654             throw $e;
00655         }
00656     }

Record::save ( Connection conn = null  ) 

Saves the data in this Record to the database.

Parameters:
Connection $conn
Returns:
boolean True if the save completed. false otherwise.
Exceptions:
DataSetException 

Definition at line 120 of file Record.php.

References DELETE, doDelete(), doInsert(), doUpdate(), INSERT, needsToBeSaved(), and UPDATE.

Referenced by delete().

00121     {
00122         $returnValue = false;
00123 
00124         if ($this->ds instanceof QueryDataSet) {
00125             throw new DataSetException("You cannot save a QueryDataSet. Please use a TableDataSet instead.");
00126         }
00127 
00128         if (!$this->needsToBeSaved()) {
00129             return $returnValue;
00130         }
00131 
00132         switch($this->saveType) {            
00133             case Record::INSERT:
00134                 $returnValue = $this->doInsert($conn);
00135                 break;
00136             case Record::UPDATE:
00137                 $returnValue = $this->doUpdate($conn);
00138                 break;                
00139             case Record::DELETE:
00140                 $returnValue = $this->doDelete($conn);
00141                 break;
00142             default:
00143                 throw new DataSetException("Invalid or no-action saveType for Record.");
00144         }
00145                 
00146         return (boolean) $returnValue;
00147     }

Record::setParentDataSet ( DataSet ds  ) 

Sets the parent DataSet for this record.

Parameters:
DataSet $ds

Definition at line 723 of file Record.php.

Referenced by __construct().

00724     {
00725         $this->ds = $ds;
00726     }

Record::setSaveType ( type  ) 

Sets the internal save type as one of the defined privates (ie: ZOMBIE).

Parameters:
int $type
Returns:
void

Definition at line 542 of file Record.php.

Referenced by delete(), doDelete(), doInsert(), doUpdate(), initializeRecord(), markForInsert(), markForUpdate(), markToBeDeleted(), and unmarkToBeDeleted().

00543     {
00544         $this->saveType = $type;
00545     }

Record::setValue ( col,
value 
)

Sets the value of col.

Returns:
Record this object.
Exceptions:
DataSetException 

Definition at line 561 of file Record.php.

References markValueDirty().

00562     {
00563         $this->values[$col] = $value;
00564         $this->markValueDirty($col);
00565         return $this;
00566     }

Record::size (  ) 

The number of columns in this object.

Returns:
the number of columns in this object

Definition at line 418 of file Record.php.

00419     {
00420         return count($this->values);
00421     }

Record::toBeSavedWithDelete (  ) 

Whether or not this Record is to be saved with an SQL delete statement.

Returns:
boolean True if saved with delete

Definition at line 445 of file Record.php.

References DELETE.

Referenced by needsToBeSaved(), and refresh().

00446     {
00447         return ($this->saveType === Record::DELETE);
00448     }

Record::toBeSavedWithInsert (  ) 

Whether or not this Record is to be saved with an SQL insert statement.

Returns:
boolean True if saved with insert

Definition at line 427 of file Record.php.

References INSERT.

Referenced by needsToBeSaved(), and refresh().

00428     {
00429         return ($this->saveType === Record::INSERT);
00430     }

Record::toBeSavedWithUpdate (  ) 

Whether or not this Record is to be saved with an SQL update statement.

Returns:
boolean True if saved with update

Definition at line 436 of file Record.php.

References UPDATE.

Referenced by needsToBeSaved().

00437     {
00438         return ($this->saveType === Record::UPDATE);
00439     }

Record::unmarkToBeDeleted (  ) 

Unmarks a record that has been marked for deletion.

WARNING: You must reset the save type before trying to save this record again.

See also:
markForUpdate()

markForInsert()

markToBeDeleted()

Exceptions:
DataSetException 

Definition at line 508 of file Record.php.

References setSaveType(), UNKNOWN, and ZOMBIE.

00509     {
00510         if ($this->saveType === Record::ZOMBIE) {
00511             throw new DataSetException ("This record has already been deleted!");
00512         }   
00513         $this->setSaveType(UNKNOWN);
00514         //return $this;
00515     }

Record::valueIsClean ( column  ) 

Determines whether or not a value stored in the record is clean.

Returns:
true if clean
Exceptions:
DataSetException 

Definition at line 594 of file Record.php.

Referenced by getRefreshSql(), and getUpdateSql().

00595     {
00596         if (!isset($this->values[$column])) {
00597             throw new DataSetException("Undefined column: ".$column);
00598         }
00599         return !isset($this->dirtyCols[$column]);
00600     }


Member Data Documentation

Record::$dirtyCols = array() [private]

array of modified (dirty) columns

Definition at line 60 of file Record.php.

Record::$ds [private]

the parent DataSet for this Record

Definition at line 63 of file Record.php.

Record::$saveType = 0 [private]

this is the state of this record

Definition at line 66 of file Record.php.

Record::$values = array() [private]

an array of values strings, indexed by column name.

Definition at line 57 of file Record.php.

Definition at line 54 of file Record.php.

Definition at line 50 of file Record.php.

Referenced by doInsert().

Definition at line 52 of file Record.php.

Referenced by doUpdate().

Definition at line 53 of file Record.php.

Definition at line 49 of file Record.php.

Definition at line 51 of file Record.php.

const Record::DELETE = 3

Definition at line 48 of file Record.php.

Referenced by delete(), markToBeDeleted(), save(), and toBeSavedWithDelete().

const Record::INSERT = 1

Definition at line 46 of file Record.php.

Referenced by markForInsert(), save(), and toBeSavedWithInsert().

const Record::UNKNOWN = 0

Definition at line 45 of file Record.php.

Referenced by initializeRecord(), and unmarkToBeDeleted().

const Record::UPDATE = 2

Definition at line 47 of file Record.php.

Referenced by markForUpdate(), save(), and toBeSavedWithUpdate().

const Record::ZOMBIE = -1

Definition at line 44 of file Record.php.

Referenced by doDelete(), isAZombie(), and unmarkToBeDeleted().


The documentation for this class was generated from the following file:

Generated on Wed May 6 23:10:50 2009 for fareofficelib by  doxygen 1.5.8