Forum.: | PortaL |:.GalleryPytësoriKërkoLista AnëtarëveGrupet e AnëtarëveRegjistrohuidentifikimi

Share | 

 Hacking ADOdb Safely

Shiko temën e mëparshme Shiko temën pasuese Shko poshtë 

Numri i postimeve : 526
Age : 23
Vendi : kosovë
Registration date : 26/09/2008

MesazhTitulli: Hacking ADOdb Safely   Wed Oct 22, 2008 12:24 am

You might want to modify ADOdb for your own purposes. Luckily you can
still maintain backward compatibility by sub-classing ADOdb and using the $ADODB_NEWCONNECTION
variable. $ADODB_NEWCONNECTION allows you to override the behaviour of ADONewConnection().
ADOConnection() checks for this variable and will call
the function-name stored in this variable if it is defined.
In the following example, new functionality for the connection object
is placed in the hack_mysql and hack_postgres7 classes. The recordset class naming convention
can be controlled using $rsPrefix. Here we set it to 'hack_rs_', which will make ADOdb use
hack_rs_mysql and hack_rs_postgres7 as the recordset classes.
class hack_mysql extends adodb_mysql {
var $rsPrefix = 'hack_rs_';
/* Your mods here */

class hack_rs_mysql extends ADORecordSet_mysql {
/* Your mods here */

class hack_postgres7 extends adodb_postgres7 {
var $rsPrefix = 'hack_rs_';
/* Your mods here */

class hack_rs_postgres7 extends ADORecordSet_postgres7 {
/* Your mods here */

$ADODB_NEWCONNECTION = 'hack_factory';

function& hack_factory($driver)
if ($driver !== 'mysql' && $driver !== 'postgres7') return false;

$driver = 'hack_'.$driver;
$obj = new $driver();
return $obj;


Don't forget to call the constructor of the parent class in your
constructor. If you want to use the default ADOdb drivers return false
in the above hack_factory() function.

PHP5 Features

ADOdb 4.02 or later will transparently determine which version of PHP you are using.
If PHP5 is detected, the following features become available:

  • PDO: PDO drivers are available. See the connection examples. Currently PDO drivers are
    not as powerful as native drivers, and should be treated as experimental.
  • Foreach iterators: This is a very natural way of going through a recordset:
    $rs = $db->Execute($sql);
    foreach($rs as $k => $row) {
    echo "r1=".$row[0]." r2=".$row[1]."<br>";
  • Exceptions: Just include and you can now
    catch exceptions on errors as they occur.
    try {
    $db = NewADOConnection("oci8");
    } catch (exception $e) {
Mbrapsht në krye Shko poshtë
Shiko profilin e anëtarit
Hacking ADOdb Safely
Shiko temën e mëparshme Shiko temën pasuese Mbrapsht në krye 
Faqja 1 e 1

Drejtat e ktij Forumit:Ju nuk mund ti përgjigjeni temave të këtij forumi
 :: PC & Console :: MMORPG-
Kërce tek: