[thelist] PHP vrs Perl - 15 rounds

Alex Farran alex at alexfarran.com
Tue Mar 9 06:23:34 CST 2004


Edwin Martin writes:

> Raditha Dissanayake wrote:
>>> PHP has this too. Don't forget to look at PEAR
>>> http://pear.php.net/manual/en/package.database.db.intro-execute.php
>>> 
>> I am not an expert on pear but my understanding is that this is
>> different from what you encounter in perl.

> It's the same.

> In PHP you can do it, just like in Perl:

> $sql = 'select * from client where clientid=? and status=?';
> $data = array( 53, 4 );
> $result = $db->query( $sql, $data );

I don't like unnamed bind variables.  It's hard to read and prone to
errors as the variable list changes.  A better interface would look
something like this -

$sql = 'select * from client where clientid=?myclient and status=?status';
$data = array( "myclient" => 53, "status" => 4 );
$result = $db->query( $sql, $data );

-- 

    __o    Alex Farran
  _`\<,_   Analyst / Programmer
 (_)/ (_)  www.alexfarran.com



More information about the thelist mailing list