Class miModelSQLRecord

Description

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

  • copyright: Mirchev Ideas Ltd. © 2003, 2004

Located in /model/SQLRecord.inc (line 23)


	
			
Direct descendents
Class Description
 class miModelGeneralOptionsRecord Handle and manage deleting and reading of data from the database.
Method Summary
 miModelSQLRecord miModelSQLRecord (string $t, string $k)
 string delete ()
 void get (mixed $p, string $u)
 array getRow ()
 string getTableName ()
 string insert ()
 bool read (string $key, mixet $value)
 bool readPK (mixet $value)
 void set (string $p, mixet $v)
 void setRow (mixed $v, array $u)
 string update ()
Methods
Constructor miModelSQLRecord (line 154)

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

Example:


1 <?php
2 $ModelSQLRecord = new miModelSQLRecord('tableName', 'tablePrimaryKey');
3 ?>

  • access: public
miModelSQLRecord miModelSQLRecord (string $t, string $k)
  • string $t: database table name
  • string $k: database table primary key
delete (line 261)

Delete a record in the table

  • return: information message with the result of execution of the command
  • access: public
string delete ()
get (line 83)

Return the value of the given field from the array which hold the data for the next execution or last executed query

Example:


1 <?php
2 $ModelSQLRecord = new miModelSQLRecord('tableName', 'tablePrimaryKey');
3 $ModelSQLRecord->readPK($value);
4 $value = $ModelSQLRecord->get($someField);
5 ?>

  • access: public
void get (mixed $p, string $u)
  • string $u: field name
getPrimaryKeyColumn (line 50)

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

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

Return array which hold the data for the next execution or last executed query

Example:


1 <?php
2 $ModelSQLRecord = new miModelSQLRecord('tableName', 'tablePrimaryKey');
3 $ModelSQLRecord->readPK($value);
4 $row = $ModelSQLRecord->getRow();
5 ?>

  • return: which hold the data for the next execution or last executed query
  • access: public
array getRow ()
getTableName (line 62)

Gets the table name of this SQLRecord

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

Insert a record in the table

  • return: information message with the result of execution of the command
  • access: public
string insert ()
read (line 178)

Read a record from a database table where specify unique field represented by $key is equal to the value represented by $value

Example:


1 <?php
2 $ModelSQLRecord = new miModelSQLRecord('tableName', 'tablePrimaryKey');
3 if ($ModelSQLRecord->read('uniqueField', $uniqueFieldValue))
4 $row = $ModelSQLRecord->getRow(); // now $row holds the result row
5 else echo 'No such record with ' . 'uniqueField = ' . $uniqueFieldValue;
6 ?>

  • return: true if the record was found, false if there is no record whit such value for the given field
bool read (string $key, mixet $value)
  • string $key: the name of the field
  • mixet $value: the value
readPK (line 209)

Read a record from a database table for a specify primary key value

Example:


1 <?php
2 $ModelSQLRecord = new miModelSQLRecord('tableName', 'tablePrimaryKey');
3 if ($ModelSQLRecord->readPK($value))
4 $row = $ModelSQLRecord->getRow(); // now $row holds the result row
5 else echo 'No such record with ' . 'uniqueField = ' . $uniqueFieldValue;
6 ?>

  • return: true if the record was found, false if there is no record whit such value for the given field
bool readPK (mixet $value)
  • mixet $value: primary key value

Redefined in descendants as:
set (line 101)

Sets a value to the given field to the array which hold the data for the next execution or last executed query

Example:


1 <?php
2 $ModelSQLRecord = new miModelSQLRecord('tableName', 'tablePrimaryKey');
3 $ModelSQLRecord->set($field, $value);
4 ?>

  • access: public
void set (string $p, mixet $v)
  • string $p: the name of the field
  • mixet $v: value of the field
setRow (line 136)

Sets array which hold the data for the next execution or last executed query

Example:


1 <?php
2 $ModelSQLRecord = new miModelSQLRecord('tableName', 'tablePrimaryKey');
3 $ModelSQLRecord->setRow($row); //$row is an array which hold data we wont to set.
4 ?>

  • access: public
void setRow (mixed $v, array $u)
  • array $u: which hold the data for the next execution or last executed query
update (line 246)

Update a record in the table

  • return: information message with the result of execution of the command
  • access: public
string update ()

Redefined in descendants as:

Documentation generated on Mon, 18 Oct 2004 14:58:32 +0300 by phpDocumentor 1.2.3