开发者

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

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!


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) );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜