Class AutoCRUD_CRUD

Description

AutoCRUD CRUD Class

This class is used for the CRUD functionality (such as insert, update, delete)

Located in /crud.inc.php (line 18)


	
			
Variable Summary
integer $currentpage
array $fields
array $indexes
string $key
string $name
array $numeric
string $orderby
bool $paging
integer $perpage
array $required
string $table
integer $totalpages
integer $totalrecords
string $where
Method Summary
AutoCRUD_CRUD AutoCRUD_CRUD (string $table)
mixed addAlias (string $str)
mixed addRelationship (AutoCRUD_CRUD &$crud_obj, string $field1, string $field2, string $type)
mixed delete ([mixed $id = ''])
array get (mixed $id)
string getName ()
mixed &getRelationship (string $table)
array getRelationships ()
mixed insert (array $args)
true join (string $table)
void quote (mixed $str)
void quoteInto (mixed $stack, mixed $needle)
bool relationship_exists (string $table)
array select ([string $key = ''])
void setParent (mixed &$obj)
void set_parent (AutoCRUD &$obj)
bool unique_error ([string $keyname = null])
mixed update (array $args, [mixed $id = ''])
Variables
integer $currentpage = 1 (line 98)

Current Page

Set the current page of records to be selected

  • access: public
array $fields = array() (line 50)

Fields Array

An array of all the fields in the table

  • access: public
array $indexes = array() (line 74)

Indexes

An array of all the indexes of this table

  • access: public
string $key (line 42)

Primary Key Field

Holds the name of the primary key field of the table

  • access: public
string $name (line 34)

Object Name

Holds the name of the CRUD object (mainly used to handle aliases)

  • access: public
array $numeric = array() (line 66)

Numeric Fields

An array of all the numeric fields of this table

  • access: public
string $orderby (line 130)

Custom ORDER BY

This property should be used to set a custom ORDER BY clause when selecting records

  • access: public
bool $paging = false (line 82)

Paginate Results

Set to true if you want to paginate the results, and false if you don't

  • access: public
integer $perpage = 25 (line 90)

Records Per Page

Set how many records should be selected per page (when paging is enabled)

  • access: public
array $required = array() (line 58)

Required Fields

An array of all the fields that are required for this table (set to 'NOT NULL')

  • access: public
string $table (line 26)

Table Name

Holds the table name of the CRUD object

  • access: public
integer $totalpages (line 106)

Total Pages

The total number of pages that are available

  • access: public
integer $totalrecords (line 114)

Total Records

The total number of records that matched the last query

  • access: public
string $where (line 122)

Custom WHERE

This property should be used to set a custom WHERE clause when updating, deleting or selecting

  • access: public
Methods
Constructor AutoCRUD_CRUD (line 149)

Sets the table name of the CRUD object

  • access: public
AutoCRUD_CRUD AutoCRUD_CRUD (string $table)
  • string $table: the table name
addAlias (line 422)

Used to add a new alias for the CRUD object

  • return: true on success, error object on failure
  • access: public
mixed addAlias (string $str)
  • string $str: the name of the new alias (mustn't already exist or be used for another table)
addRelationship (line 466)

Used to setup a new relationship with another table

  • return: true on success, error object on failure
  • access: public
mixed addRelationship (AutoCRUD_CRUD &$crud_obj, string $field1, string $field2, string $type)
  • AutoCRUD_CRUD $crud_obj: the CRUD object of the other table
  • string $field1: the field in this table that's used in the relationship
  • string $field2: the field in the other table that's used in the relationship
  • string $type: the type of relationship (one-to-one, one-to-many, many-to-many, child-parent)
delete (line 289)

Used to delete an existing record, like this:

  1. $crud->table->delete (23);

  • return: true on success, error object on failure
  • access: public
mixed delete ([mixed $id = ''])
  • mixed $id: the ID of the record you want to delete
get (line 390)

Used to get a single record, like this:

  1. $record = $crud->table->get(23);

  • return: the record, as an associative array
  • access: public
array get (mixed $id)
  • mixed $id: you can pass the record ID to this function to get a specified record (optional)
getName (line 442)

Returns the name of the CRUD object (mainly used with aliases)

  • return: the name of the CRUD object
  • access: public
string getName ()
getParent (line 178)

Returns the parent of the CRUD object

  • return: the parent of the CRUD object
  • access: public
AutoCRUD &getParent ()
getRelationship (line 500)

Returns a relationship object with another table

  • return: the relationship object on success, an error object on failure
  • access: public
mixed &getRelationship (string $table)
  • string $table: the name of the other table
getRelationships (line 452)

Returns all the relationships that have been set with other table

  • return: the relationships
  • access: public
array getRelationships ()
insert (line 192)

Used to insert a new record, like this:

  1. $crud->table->insert (array('title' => 'My test record', 'description' => 'A test!'));

  • return: ID of the record inserted on success, an error object on failure
  • access: public
mixed insert (array $args)
  • array $args: array of the record data
join (line 535)

Used to get related records from another table when selecting

  • return: on success, error object on failure
  • access: public
true join (string $table)
  • string $table: the name of the other table
quote (line 611)

Raw MySQL Function

void quote (mixed $str)
quoteInto (line 616)

Raw MySQL Function

void quoteInto (mixed $stack, mixed $needle)
relationship_exists (line 524)

Used to check whether a relationship with another table exists

  • return: whether the relationship exists or not
  • access: public
bool relationship_exists (string $table)
  • string $table: the name of the other table
select (line 321)

Used to select a list of records, like this:

  1. $records = $crud->table->select();

  • return: an array of records (or an empty array when there are no records)
  • access: public
array select ([string $key = ''])
  • string $key: the field name under which the records should be stored
setParent (line 168)
void setParent (mixed &$obj)
set_parent (line 160)

Sets the parent of this CRUD object

  • access: public
void set_parent (AutoCRUD &$obj)
  • AutoCRUD $obj: the parent of the CRUD object
unique_error (line 575)

Used to check if a unique error happened

  • return: whether a unique error has happened or not
  • access: public
bool unique_error ([string $keyname = null])
  • string $keyname: the name of a specific index
update (line 241)

Used to update an existing record, like this:

  1. $crud->table->update (array('title' => 'Updated'), 23);

  • return: true on success, error object on failure
  • access: public
mixed update (array $args, [mixed $id = ''])
  • array $args: the new data of the record
  • mixed $id: record ID of the record you want to update

Documentation generated on Wed, 14 Jun 2006 14:08:42 +0200 by phpDocumentor 1.3.0RC4