Class miSqlRecord

Description

Handle and manage the inserting, updating, deleting and reading of data from the database. This class works only with one record row specified by a table primary key or unique field.

  • copyright: Copyright (c) 2003-2006 Mirchev Ideas Ltd. All rights reserved.

Located in /model/SqlRecord.php (line 23)


	
			
Direct descendents
Class Description
miPropertiesRecord Handle and manage deleting and reading of data from the database.
miSqlComplexPKRecord SQL Record managerment class for records with complex primary keys
Variable Summary
mixed $_primaryKey
mixed $_row
mixed $_table
Method Summary
miSqlRecord __construct (string $table, string $primaryKey)
PK delete ()
mixed get (string $field)
mixed getPK ()
array getRow ()
string getTableName ()
PK insert ()
void read (string $key, string $value)
void readPK (mixed $value)
void set (string $field, mixed $value)
void setRow (array $dataRow)
PK update ()
Variables
mixed $_primaryKey = '' (line 41)
  • access: protected
mixed $_row = array() (line 29)
  • access: protected
mixed $_table = '' (line 35)
  • access: protected
Methods
Constructor __construct (line 59)

miSqlRecord constructor. It takes two parameters table name and table primary key

Example:

  1.  <?php
  2.  $record new miSqlRecord('tableName''tablePrimaryKey');
  3.  ?>

  • access: public
miSqlRecord __construct (string $table, string $primaryKey)
  • string $table: database table name
  • string $primaryKey: database table primary key

Redefined in descendants as:
delete (line 263)

Delete a record in the db table

  • return: the primary key of the deleted record
  • throws: miDBException
  • access: public
PK delete ()

Redefined in descendants as:
get (line 105)

Gets the value of a field

Example:

  1.  <?php
  2.  $record new miSqlRecord('tableName''tablePrimaryKey');
  3.  $record->readPK($value);
  4.  $value $record->get($someField);
  5.  ?>

  • return: the field value
  • access: public
mixed get (string $field)
  • string $field: field name
getPK (line 115)

Gets the value of the primary key

  • return: the primary key value
  • access: public
mixed getPK ()
getPrimaryKeyColumn (line 72)

Gets the primary key column of the table that this SQLRecord uses

  • return: the primary key column name
  • access: public
string getPrimaryKeyColumn ()
getRow (line 154)

Return the data row as array

Example:

  1.  <?php
  2.  $record new miSqlRecord('tableName''tablePrimaryKey');
  3.  $record->readPK($value);
  4.  $row $record->getRow();
  5.  ?>

  • return: the data row
  • access: public
array getRow ()
getTableName (line 84)

Gets the table name of this SQLRecord

  • return: the table name
  • access: public
string getTableName ()
insert (line 236)

Insert a record in the db table It also updates the the PK value of the inserted row

  • return: the primary key of the newly created record
  • throws: miDBException
  • access: public
PK insert ()

Redefined in descendants as:
read (line 196)

Read a record where the specified field represented by $key is equal to the value represented by $value If there are is than one record matching the first one will be read in

Example:

  1.  <?php
  2.  $record new miSqlRecord('tableName''tablePrimaryKey');
  3.  $record->read('uniqueField'$uniqueFieldValue);
  4.  ?>

  • throws: miDBException
  • access: public
void read (string $key, string $value)
  • string $key: the name of the field
  • string $value: the value
readPK (line 222)

Read a record using the specified primary key value

Example:

  1.  <?php
  2.  $record new miSqlRecord('tableName''tablePrimaryKey');
  3.  $record->readPK($value);
  4.  ?>

  • throws: miDBException
  • access: public
void readPK (mixed $value)
  • mixed $value: primary key value

Redefined in descendants as:
set (line 134)

Sets the value of a field

Example:

  1.  <?php
  2.  $record new miSqlRecord('tableName''tablePrimaryKey');
  3.  $record->set($field$value);
  4.  ?>

  • access: public
void set (string $field, mixed $value)
  • string $field: the name of the field
  • mixed $value: value of the field
setRow (line 173)

Directly set the data row

Example:

  1.  <?php
  2.  $record new miSqlRecord('tableName''tablePrimaryKey');
  3.  $record->setRow($row);
  4.  ?>

  • access: public
void setRow (array $dataRow)
  • array $dataRow: the data row
update (line 249)

Update a record in the db table

  • return: the primary key of the updated record
  • throws: miDBException
  • access: public
PK update ()

Redefined in descendants as:

Documentation generated on Thu, 08 May 2008 16:57:35 +0300 by phpDocumentor 1.4.1