ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:activerecord:getactiverecords

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
Next revisionBoth sides next revision
activerecord:getactiverecords [2015/12/05 01:11] mnewnhamactiverecord:getactiverecords [2015/12/05 17:10] mnewnham
Line 2: Line 2:
 ~~NOTOC~~ ~~NOTOC~~
 <WRAP right box> <WRAP right box>
-== syntax == +== Syntax == 
-  void getActiveRecords(+  bool getActiveRecords(
     string $tableName,     string $tableName,
     optional string  $where=false,     optional string  $where=false,
Line 11: Line 11:
  
 </WRAP> </WRAP>
-====== getActiveRecordsClass ====== +-------------------------------------
-~~NOTOC~~ +
-<WRAP right box> +
-== syntax == +
-  void getActiveRecordsClass( +
-   string $class, +
-   string $tableName, +
-   optional string  $where=false, +
-   optional mixed[] $bindarr=false, +
-   optional mixed[] $primaryKeyArray=false, +
-   optional mixed[] $queryExtras=array(), +
-   optional mixed[] $relationsData=array() +
-  ) +
- +
-</WRAP> +
 ===== Description ===== ===== Description =====
- +This method retrieves an array of ADOdb_Active_Records.
-GetActiveRecordsClass Performs an 'ALL' query  +
 ===== Parameters =====  ===== Parameters ===== 
  
Line 38: Line 21:
  Where clause  Where clause
 ==== $bindarr ==== ==== $bindarr ====
 +For more information on the use of ''Bind'' variables, see [[reference:execute()]].
 ==== $primaryKeyArray ==== ==== $primaryKeyArray ====
    
Line 49: Line 32:
 $db->connect('','user','password','employees'); $db->connect('','user','password','employees');
  
-$activeRecs = $db->GetActiveRecords('departments'); +$table        = 'departments'; 
-           +$whereOrderBy = "name LIKE 'A%' ORDER BY Name"; 
 +$primaryKeys  = array('id'); 
 +$activeRecArr = $db->getActiveRecords($table, $whereOrderBy,$primaryKeys); 
 +foreach($activeRecArr as $rec)  
 +
 +    $rec->id = rand(); 
 +    $rec->save(); 
 +          
 </code> </code>
 {{tag>[Active_Record]}}        {{tag>[Active_Record]}}       
v5/activerecord/getactiverecords.txt · Last modified: 2018/07/02 14:19 by peterdd