[UPHPU] MySQL Syntax
Timothy Humphrey
timothy.humphrey at gmail.com
Wed Aug 17 09:22:14 MDT 2005
Steve Dibb wrote:
> Timothy Humphrey wrote:
>> [1]
>> require_once('DB.php');
>> $db = DB::connect("mysql://user:pass@localhost/webdb");
>> $q = $db->query("SELECT * FROM webdb_table");
>> while($q->fetchInto($row)) {
>> echo "";
>> }
>>
>> with shortcuts like:
>> $data = $db->getAll("SELECT * FROM webdb_table");
>>
>> [2]
>> mysql_connect("localhost", "user", "pass");
>> mysql_select_db("webdb");
>> $query = mysql_query("SELECT * FROM webdb_table");
>> while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) {
>> echo "";
>> }
>>
>
> Well, they aren't two different ways to connect to MySQL. One is using
> PEAR's DB class (1) and the other is using PHP's native mysql functions
> (2). PEAR's class will use #2 anyway, its just transparent to the user.
> You would use the same syntax with PEAR::DB to connect to any database
> it supported, except you would replace mysql:// with the other db
> connection string, like pgsql:// or sqlite:// or mssql://
I see... of course. So how would one perform a $db->commit(); and
$db->rollback(); with [2]? Or does anyone really use $db->commit();?
More information about the UPHPU
mailing list