v5:activerecord:getactiverecordsclass
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
activerecord:getactiverecordsclass [2015/12/05 01:55] – mnewnham | v5:activerecord:getactiverecordsclass [2018/07/02 14:17] (current) – prefer functions start lowercase (#430) peterdd | ||
---|---|---|---|
Line 16: | Line 16: | ||
===== Description ===== | ===== Description ===== | ||
- | + | This allows you to retrieve | |
- | GetActiveRecordsClass Performs | + | |
===== Parameters ===== | ===== Parameters ===== | ||
Line 27: | Line 26: | ||
| | ||
==== $bindarr ==== | ==== $bindarr ==== | ||
- | For more information on the use of '' | + | For more information on the use of '' |
==== $primaryKeyArray ==== | ==== $primaryKeyArray ==== | ||
Line 36: | Line 35: | ||
==== Usage ==== | ==== Usage ==== | ||
<code php> | <code php> | ||
- | include | + | class Product extends ADOdb_Active_Record{}; |
- | include | + | $table = 'products'; |
+ | $whereOrderBy = "name LIKE 'A%' ORDER BY Name"; | ||
+ | $activeRecArr = $db-> | ||
+ | $table, | ||
+ | $whereOrderBy); | ||
- | $db = NewADOConnection('mysqli'); | + | /* |
- | $db->connect('',' | + | * the objects in $activeRecArr are of class 'Product' |
+ | */ | ||
+ | foreach($activeRecArr as $rec) { | ||
+ | $rec-> | ||
+ | $rec-> | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | To use bind variables (assuming ? is the place-holder for your database): | ||
+ | <code php> | ||
+ | |||
+ | $activeRecArr = $db->getActiveRecordsClass($className, | ||
+ | array('A%')); | ||
+ | /* | ||
+ | * You can also define the primary keys of the table by passing an array of field names: | ||
+ | */ | ||
+ | |||
+ | $activeRecArr = $db-> | ||
+ | array('A%'), array(' | ||
- | $activeRecs = $db-> | ||
- | |||
</ | </ | ||
+ | |||
{{tag> | {{tag> |
v5/activerecord/getactiverecordsclass.1449276953.txt.gz · Last modified: 2017/04/21 11:21 (external edit)