<?php
include 'Dbo.php';
$cstring = 'host=localhost;user=mysql;password=mysql123;database=mydb;persistent=true';
$sql = Dbo::connect( $cstring, 'MySql' );
echo '<pre>';
print_r( $sql->query( 'select * from mytable' )->fetchAll() );
echo '</pre>';
function myfunction( $arg ) {
return Dbo::getHandle()->query( 'select '.$arg.' from mytable' )->fetch();
}
/* Multiple databases possible */
$cstring2 = 'host=127.0.0.2;user=mysql;password=mysql123;database=mydb;persistent=true';
Dbo::connect( $cstring2, 'MySql', 'scon' );
print_r( Dbo::getHandle( 'scon' )->query( 'select * from myothertable' )->fetchAll() );
?>
|