views:

49

answers:

1

Hi, the question is very straightforward: Good DAL library for PHP which has the similar .Net's feature: command.Parameters.AddWithValue("@demographics", demoXml).

mysqli extension is good but I want to have the aforementioned feature too. Putting many "?" does not look nice and rather confusing when a table has many fiends (>= 8). Thanks in advance!

+2  A: 

PDO has named parameters.

e.g.

$stmt = $pdo->prepare('INSERT INTO foo (id,x) VALUES (:id,:value)');

$params = array();
$stmt->bindParam(':id', $params['id']);
$stmt->bindParam(':value', $params['value']);

$params['id'] = 200;
$params['value']= 1100;
$stmt->execute();

$params['id'] = 201;
$params['value']= 1101;
$stmt->execute();

or

$stmt = $pdo->prepare('INSERT INTO foo (id,x) VALUES (:id,:value)');

$stmt->execute( array(':id'=>200, ':value'=>1100) );
$stmt->execute( array(':id'=>201, ':value'=>1101) );
VolkerK
+1. That's nice! Thanks for your help. How could I overlook the PDO :D
Viet