ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:activerecord:setdatabaseadapter

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
Last revisionBoth sides next revision
activerecord:setdatabaseadaptor [2015/12/06 02:48] – [Description] mnewnhamv5:activerecord:setdatabaseadaptor [2022/06/09 18:14] – setDatabaseAdaptor -> setDatabaseAdapter dregad
Line 1: Line 1:
-====== setDatabaseAdaptor ======+====== setDatabaseAdapter ======
 ~~NOTOC~~ ~~NOTOC~~
 <WRAP right box> <WRAP right box>
 +== See Also ==
 +[[v5:activerecord:dbat|$_dbat Class Variable]]
 == Syntax == == Syntax ==
    bool ADODB_Active_Record::setDatabaseAdapter(    bool ADODB_Active_Record::setDatabaseAdapter(
Line 9: Line 11:
 </WRAP> </WRAP>
 ===== Description ===== ===== Description =====
-This 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. Note that even though multiple connections can be attached to the base class, only one can be used, so the class must be extended  to use the connections +This 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. Note that even though multiple connections can be attached to the base class, only one can be used, so the class must be extended  to use the connections 
 ------------------------ ------------------------
 ===== Usage ===== ===== Usage =====
Line 15: Line 19:
 <code php> <code php>
 $db = newAdoConnection('mysqli'); $db = newAdoConnection('mysqli');
-$ADOdb_Active_Record::setDatabaseAdaptor($db);+$db->connect(...); 
 +$ADOdb_Active_Record::setDatabaseAdapter($db);
 </code> </code>
 Example, multiple connections Example, multiple connections
Line 21: Line 26:
 $db  = NewADOConnection('mysqli'); $db  = NewADOConnection('mysqli');
 $db2 = NewADOConnection('oci8'); $db2 = NewADOConnection('oci8');
 +
 +$db->connect(...);
 +$db2->connect(...);
  
 ADOdb_Active_Record::SetDatabaseAdapter($db,'mConnection'); ADOdb_Active_Record::SetDatabaseAdapter($db,'mConnection');
Line 38: Line 46:
     * Assigns the oracle connection to this class     * Assigns the oracle connection to this class
     */      */ 
-    public $_dbat = 'moonnection';+    public $_dbat = 'oConnection';
 } }
  
  
 </code> </code>
v5/activerecord/setdatabaseadapter.txt · Last modified: 2022/06/09 18:15 by dregad