Would you like to react to this message? Create an account in a few clicks or log in to continue.



 
Forum.: | PortaL |:.GalleryLatest imagesKërkoRegjistrohuidentifikimi

 

 Hacking ADOdb Safely

Shko poshtë 
AutoriMesazh
Mr.VisarS
AdministratoR/DesigneR
AdministratoR/DesigneR
Mr.VisarS


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

Hacking ADOdb Safely Empty
MesazhTitulli: Hacking ADOdb Safely   Hacking ADOdb Safely Icon_minitimeWed 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;
}

include_once('adodb.inc.php');


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:
    $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
    $rs = $db->Execute($sql);
    foreach($rs as $k => $row) {
    echo "r1=".$row[0]." r2=".$row[1]."<br>";
    }
  • Exceptions: Just include adodb-exceptions.inc.php and you can now
    catch exceptions on errors as they occur.
    include("../adodb-exceptions.inc.php");
    include("../adodb.inc.php");
    try {
    $db = NewADOConnection("oci8");
    $db->Connect('','scott','bad-password');
    } catch (exception $e) {
    var_dump($e);
    adodb_backtrace($e->gettrace());
    }
Mbrapsht në krye Shko poshtë
http://www.loqka-chat.tk
 
Hacking ADOdb Safely
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: