especialjie 2008-04-25
CMSPAD1.2版开始,系统在支持数据库集群和主从数据库基础上,开始支持SQL预编译和批量执行特性了,下面看看如何执行吧:
<?php require_once './kernel/global.php'; $db = cmspad_database(); // 执行一条SQL语句 $db->query('SELECT * FROM hello'); // 批量执行SQL语句 $db->addBatch('UPDATE hello SET world = 1 WHERE id = 7'); $db->addBatch('UPDATE hello SET world = 2 WHERE id = 8'); $db->addBatch('UPDATE hello SET world = 3 WHERE id = 9'); $db->executeBatch(); // 预编译SQL语句 $stmt = $db->prepare('SELECT * FROM hello WHERE id = ?'); $stmt->setInteger(0, 7); $resultSet = $stmt->execute(); $stmt->close(); ?>