ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:activerecord:activerecord_index

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
activerecord:active_record [2015/12/06 02:00] – [Static Active Record Methods] mnewnhamv5:activerecord:activerecord_index [2022/06/09 18:37] (current) – ↷ Links adapted because of a move operation 3.83.52.90
Line 1: Line 1:
 +<WRAP right box>
 +[[v5:activerecord:Index]]
 +</WRAP>
 ====== ADOdb Active Record ====== ====== ADOdb Active Record ======
 ===== Introduction ===== ===== Introduction =====
  
-ADOdb_Active_Record is an [[wp>Object-relational_mapping|Object Relation Mapping]] (ORM) implementation using PHP. In an ORM system, the tables and rows of the database are abstracted into native PHP objects. This allows the programmer to focus more on manipulating the data and less on writing SQL queries.+**ADOdb Active Record** is an [[wp>Object-relational_mapping|Object Relation Mapping]] (ORM) implementation using PHP. In an ORM system, the tables and rows of the database are abstracted into native PHP objects. This allows the programmer to focus more on manipulating the data and less on writing SQL queries.
  
-The ADODB Active Method library takes advantage of all the functionality of the underlying [[userguide:index|ADOdb]] system, from table naming and casing control , mutiple database connections to features such as recordset caching. +The ADODB Active Method library takes advantage of all the functionality of the underlying [[v5:userguide:userguide_index|ADOdb]] system, from table naming and casing control, mutiple database connections to features such as recordset caching. 
  
-Thre are a couple of simple rules that help aid development, especially when developing simple applications in a rapid development environment. Following these rules will avoid additional configuration requirement:+Thre are a couple of simple rules that aid development, especially when developing simple applications in a rapid development environment. Following these rules will avoid additional configuration requirement:
  
   * The table and column names should be a consistent case in case sensitive environments.   * The table and column names should be a consistent case in case sensitive environments.
   * The table and column names should not include special characters or reserved words.   * The table and column names should not include special characters or reserved words.
   * The name of the table should be a plural, based on the name of class, so for example, a class name of ''person'', should be provided by a table name of ''persons'', not ''people''.   * The name of the table should be a plural, based on the name of class, so for example, a class name of ''person'', should be provided by a table name of ''persons'', not ''people''.
-  * The unique identifier, and primary key for the record for each table should be called ''id'' +  * The unique identifier, and primary key for the record for each table should be called ''id'' 
 +  * The fields in the Active record are bound by the same restraints as the columns in the database, e.g., if a field is declared as NOT NULL in the database, it must follow the same rule in the Active Record. 
  
-Any of the above items can be configured differently, but requires overriding default behaviours. 
  
-===== Additional functionality ===== +''ADODb Active Record'' is designed upon the principles of the ''ActiveRecord'' design pattern, which was first described by [[wp>Martin_Fowler_(software_engineer)|Martin Fowler]]. The ''ActiveRecord'' pattern has been implemented in many forms across the spectrum of programming languages. ''ADODb Active Record'' attempts to represent the database as closely to native PHP objects as possible.
-''ADOdb_Active_Record'' is designed upon the principles of the ''ActiveRecord'' design pattern, which was first described by [[wp>Martin_Fowler|Martin Fowler]]. The ''ActiveRecord'' pattern has been implemented in many forms across the spectrum of programming languages. ''ADOdb_Active_Record'' attempts to represent the database as closely to native PHP objects as possible.+
  
-''ADOdb_Active_Record'' maps a database table to a PHP class, and each instance of that class represents a table row. Relations between tables can also be defined, allowing the ADOdb_Active_Record objects to be nested.+''ADODb Active Record'' maps a database table to a PHP class, and each instance of that class represents a table row. Relations between tables can also be defined, allowing the ADODb Active Record objects to be nested.
  
-ADOdb Active Record functions support the [[reference:cacheexecute|Record Caching]] functions of ADOdb+ADOdb Active Record functions support the [[v5:reference:connection:cacheexecute|Record Caching]] functions of ADOdb.
 ===== Using ADOdb Active Record ===== ===== Using ADOdb Active Record =====
-See the [[activerecord:active_record_tutorial|tutorial]]+See the [[v5:activerecord:active_record_tutorial|tutorial]]
  
 ===== Developer Reference ===== ===== Developer Reference =====
  
 ==== Active Record Methods ==== ==== Active Record Methods ====
-^ Method                                 ^ Description                                                                                ^ +^ Method                                ^ Description                                                                                ^ 
-^ [[activerecord:getAttributeNames()]]   | Returns them names in an ADOdb_Active_Record object                                        +^ [[v5:activerecord:getattributenames]]  | Returns the names in an ADODb Active Record object                                         
-^ [[activerecord:save()]]                | Updates the object to the database                                                         | +^ [[v5:activerecord:save]]               | Updates the object to the database                                                         | 
-^ [[activerecord:replace()]]             | Inserts or Updates an object                                                               | +^ [[v5:activerecord:replace]]            | Inserts or Updates an object                                                               | 
-^ [[activerecord:load()]]                | Loads an object from the database                                                          | +^ [[v5:activerecord:load]]               | Loads an object from the database                                                          | 
-^ [[activerecord:find()]]                | Finds an object in the database                                                            | +^ [[v5:activerecord:find]]               | Finds an object in the database                                                            | 
-^ [[activerecord:set()]]                 | Converts an an array to an ADOdb_Active_Record object                                      | +^ [[v5:activerecord:set]]                | Converts an an array to an ADODb Active Record object                                      | 
-^ [[activerecord:hasMany()]]             | Deprecated General class replaced by classHasMany, tableHasMany and tableKeyHasMany        | +^ [[v5:activerecord:hasmany]]            | Deprecated General class replaced by classHasMany, tableHasMany and tableKeyHasMany        | 
-^ [[activerecord:belongsTo()]]           | Deprecated General class replaced by classBelongsTo, tableBelongsTo and tableKeyBelongsTo +^ [[v5:activerecord:belongsto]]          | Deprecated General class replaced by classBelongsTo, tableBelongsTo and tableKeyBelongsTo 
-^ [[activerecord:loadRelations()]]       | Loads a subset of data in a relationship                                                   |+^ [[v5:activerecord:loadrelations]]      | Loads a subset of data in a relationship                                                   
 +^ [[v5:activerecord:lastinsertid]]       | Retrieves the last insert id of a database                                                 |
 ==== Static Active Record Methods ==== ==== Static Active Record Methods ====
 ^Method^Description^ ^Method^Description^
-^[[activerecord:classHasMany()]]|Sets a one-to-many Active Record relationship| +^[[v5:activerecord:classhasmany]]|Sets a one-to-many Active Record relationship| 
-^[[activerecord:tableHasMany()]]|Sets a one-to-many Active Record table relationship| +^[[v5:activerecord:tablehasmany]]|Sets a one-to-many Active Record table relationship| 
-^[[activerecord:tableKeyHasMany()]]|Sets a one-to-many Active Record table key relationship| +^[[v5:activerecord:tablekeyhasmany]]|Sets a one-to-many Active Record table key relationship| 
-^[[activerecord:classBelongsTo()]]|Sets the parent of a many-to-one Active Record relationship| +^[[v5:activerecord:classbelongsto]]|Sets the parent of a many-to-one Active Record relationship| 
-^[[activerecord:tableBelongsTo()]]|Sets the parent of a many-to-one Active Record table relationship| +^[[v5:activerecord:tablebelongsto]]|Sets the parent of a many-to-one Active Record table relationship| 
-^[[activerecord:tableKeyBelongsTo()]]|Sets the parent of a many-to-one Active Record table key relationship| +^[[v5:activerecord:tablekeybelongsto]]|Sets the parent of a many-to-one Active Record table key relationship| 
-^[[activerecord:setDatabaseAdaptor()]]  | Sets the database connection for an Active Record class                                    |+^[[v5:activerecord:setdatabaseadapter]]  |Sets the database connection for an Active Record class|
 ==== Associated Connection Methods ==== ==== Associated Connection Methods ====
 ^Method^Description^ ^Method^Description^
-^[[activerecord:getActiveRecords()]]|Reads Active Records directly from a connection into an array| +^[[v5:activerecord:getactiverecords]]|Reads Active Records directly from a connection into an array| 
-^[[activerecord:getActiveRecordsClass()]]|Reads Active Records directly from a connection into objects|+^[[v5:activerecord:getactiverecordsclass]]|Reads Active Records directly from a connection into objects|
  
 ==== Class Variables ==== ==== Class Variables ====
-^Variable^Description^ +^ Variable                       ^ Description                          
-^[[activerecord:$_quoteNames]]|Quotes column names|+^ [[v5:activerecord:quotenames]]  | Quotes column names                  | 
 +^ [[v5:activerecord:table]]       | Overrides the associated table name  | 
 +^ [[v5:activerecord:dbat]]        | Overrides the database connection    | 
 +^ [[v5:activerecord:where]]       | Sets a default where statement for load()| 
 +^ [[v5:activerecord:lockmode]]     | Applies a SELECT lock operation      |
  
 +==== Global Variables ===
 +^ Variable                       ^ Description                          ^
 +^$ADODB_ACTIVE_CACHESECS|Set to true to enable caching of metadata such as field info|
 +^$ACTIVE_RECORD_SAFETY|Set to false to disable safety checks. This confirms that the structure of the active record matches the structure of the associated table|
 +^$ADODB_ACTIVE_DEFVALS|Use default values of table definition when creating new active record.|
 ------------------------------------------- -------------------------------------------
 <WRAP right box round> <WRAP right box round>
Line 68: Line 80:
 ==== Extended Active Record Methods ==== ==== Extended Active Record Methods ====
 ^Method^Description^ ^Method^Description^
-^[[activerecord:find()]]|finds an ADOdb_Active_Record object in a database|+^[[v5:activerecord:find]]|finds an ADODb Active Record object in a database|
v5/activerecord/activerecord_index.1449363609.txt.gz · Last modified: 2017/04/21 11:21 (external edit)