v5:userguide:active_record
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
userguide:active_record [2015/12/04 21:01] – mnewnham | v5:userguide:active_record [2019/05/08 16:32] (current) – [Setting the Table Name] ADODB_ASSOC_CASE not $ADODB_ASSOC_CASE dregad | ||
---|---|---|---|
Line 15: | Line 15: | ||
* Works with PHP4 and PHP5 and provides equivalent functionality in both versions of PHP. | * Works with PHP4 and PHP5 and provides equivalent functionality in both versions of PHP. | ||
* ADOdb_Active_Record works when you are connected to multiple databases. Zend's only works when connected to a default database. | * ADOdb_Active_Record works when you are connected to multiple databases. Zend's only works when connected to a default database. | ||
- | * Support for [[reference: | + | * Support for [[v5:reference:adodb_assoc_case]]. The field names are upper-cased, |
* No field name conversion to camel-caps style, unlike Zend's implementation which will convert field names such as ' | * No field name conversion to camel-caps style, unlike Zend's implementation which will convert field names such as ' | ||
* NewADOConnection:: | * NewADOConnection:: | ||
Line 152: | Line 152: | ||
We provide two ways to define your own table: | We provide two ways to define your own table: | ||
- | 1. Use a constructor parameter to override the default table naming behaviour. | + | - Use a constructor parameter to override the default table naming behaviour. |
+ | class person extends ADOdb_Active_Record {} | ||
+ | $person = new person(' | ||
+ | </ | ||
+ | - Define it in a class declaration: | ||
+ | class person extends ADOdb_Active_Record | ||
+ | { | ||
+ | var $_table = ' | ||
+ | } | ||
+ | $person = new person(); | ||
+ | </ | ||
- | class person extends ADOdb_Active_Record{} | + | ==== ADODB_ASSOC_CASE ==== |
- | $person | + | |
- | 2. Define it in a class declaration: | + | |
- | class person extends ADOdb_Active_Record | + | This allows you to control the case of field names and properties. For example, in Oracle all field names are uppercase by default, so you can force them to lowercase using '' |
- | { | + | |
- | var $_table = 'People'; | + | |
- | } | + | |
- | $person = new person(); | + | |
- | $ADODB_ASSOC_CASE | + | |
- | This allows you to control the case of field names and properties. For example, all field names in Oracle are upper-case by default. So you can force field names to be lowercase using $ADODB_ASSOC_CASE. Legal values are as follows: | + | For further details on valid values |
- | 0: lower-case | + | <code php> |
- | 1: upper-case | + | // ADODB_ASSOC_CASE == ADODB_ASSOC_CASE_LOWER |
- | 2: native-case | + | |
- | So to force all Oracle field names to lower-case, use | + | |
- | + | ||
- | $ADODB_ASSOC_CASE = 0; | + | |
$person = new person(' | $person = new person(' | ||
$person-> | $person-> | ||
- | $ADODB_ASSOC_CASE = 2; | + | |
+ | // ADODB_ASSOC_CASE == ADODB_ASSOC_CASE_UPPER | ||
$person2 = new person(' | $person2 = new person(' | ||
$person2-> | $person2-> | ||
- | Also see $ADODB_ASSOC_CASE. | + | </ |
- | ADOdb_Active_Record:: | + | ==== ADOdb_Active_Record:: |
Saves a record by executing an INSERT or UPDATE SQL statement as appropriate. | Saves a record by executing an INSERT or UPDATE SQL statement as appropriate. | ||
Line 188: | Line 188: | ||
Returns 0 on failed UPDATE, and 1 on UPDATE if data has changed, and -1 if no data was changed, so no UPDATE statement was executed. | Returns 0 on failed UPDATE, and 1 on UPDATE if data has changed, and -1 if no data was changed, so no UPDATE statement was executed. | ||
- | ADOdb_Active_Record:: | + | ==== ADOdb_Active_Record:: |
ADOdb supports replace functionality, | ADOdb supports replace functionality, | ||
Line 210: | Line 210: | ||
</ | </ | ||
- | ADOdb_Active_Record:: | + | ==== ADOdb_Active_Record:: |
We want to retrieve an array of active records based on some search criteria. For example: | We want to retrieve an array of active records based on some search criteria. For example: | ||
<code php> | <code php> | ||
class person extends ADOdb_Active_Record { | class person extends ADOdb_Active_Record { | ||
- | var $_table = ' | + | |
} | } | ||
Line 221: | Line 221: | ||
$peopleArray = $person-> | $peopleArray = $person-> | ||
</ | </ | ||
+ | |||
===== Quoting Identifiers ===== | ===== Quoting Identifiers ===== | ||
v5/userguide/active_record.1449259268.txt.gz · Last modified: 2017/04/21 11:39 (external edit)