Exemplo n.º 1
0
// experiment using "magic methods"
//users2 is the table name... you can see where this can go...
$result = $DB->users2->FetchAll();
//SERVER::dump($result);
$DB->CloseConnection();
//CLOSE DATABASE
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//
//									MYSQLi
//
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
require_once 'lib/dbi.class.php';
/*
MYSQL dynamic fetch... work in progress... 
used in my user search page we had to build
It looks bulkey, but the power comes from its ability to dynamicly build complex sqli securly... 
/*/
$myDBI = new DBI($DBc, true);
$fetchParams = array('select_items' => array('id', 'username', 'email', 'fname', 'lname', 'lastlogin', 'num_sucess_login', 'num_fail_login', 'blocked'), 'from' => 'users2', 'where_items' => array(array('condition' => 'AND', 'field' => 's:username', 'operator' => '=', 'value' => 'jordan'), array('condition' => 'OR', 'field' => 's:username', 'operator' => 'LIKE', 'value' => '%bob%')));
//SERVER::dump($fetchParams); // preview fetch params
$searchResults = $myDBI->FetchRows($fetchParams, $meta);
//SERVER::dump($searchResults);
/*note* nice addition would be ability to use equivalent of perenthises
perhaps a group of conditions inside an array.. would require recursion however
*/
$myDBI->Disconnect();