ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:activerecord:setdatabaseadapter

This is an old revision of the document!


setDatabaseAdaptor

Syntax
 ADOdb_Active_Record::SetDatabaseAdapter(
     resource $database
 )

Description

This allows reading from one database and inserting it into another using Active Records


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.1449276910.txt.gz · Last modified: 2017/04/21 11:21 (external edit)