ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:activerecord:setdatabaseadapter

This is an old revision of the document!


setDatabaseAdaptor

Syntax
 bool ADODB_Active_Record::setDatabaseAdapter(
     resource $database,
     optional string $label=''
 )

Description

This allows links the Active Record class to an ADOdb database connection. The method returns true if it is a valid connection, or false if not. The optional $label parameter allows multiple database connections to be assigned to the same ADODB_Active_Record class


Usage

$db = NewADOConnection(...);
$db2 = NewADOConnection(...);
 
ADOdb_Active_Record::SetDatabaseAdapter($db2);
 
$activeRecs = $db->GetActiveRecords('table1');
 
foreach($activeRecs as $rec) 
{
   $rec2 = new ADOdb_Active_Record('table2',$db2);
   $rec2->id = $rec->id;
   $rec2->name = $rec->name;
   $rec2->Save();
}
v5/activerecord/setdatabaseadapter.1449365128.txt.gz · Last modified: 2017/04/21 11:21 (external edit)