与
ESC
输入关键词搜索文章

phalcon单独执行select update等sql语句

全文约 110 字预计阅读 1 分钟
这里简单举例下phalcon执行sql执行方法,具体看devtools下的pdo.php文件。 在控制器下可以执行以下代码:
$success = $this->di->get('db')->query("update netpc set webname = 'netpc.com.cn' where id = $id");

print_r($success->numRows());
其他方式:
* <code>
* $result = $this->di->get('db')->query("SELECTFROM robots ORDER BY name");
* $result->setFetchMode(Phalcon\Db::FETCH_OBJ);
* while ($robot = $result->fetch()) {
* echo $robot->name;
* }
* </code>
* <code>
* $result = $this->di->get('db')->query("SELECTFROM robots ORDER BY name");
* $result->setFetchMode(Phalcon\Db::FETCH_NUM);
* while ($robot = result->fetchArray()) {
* print_r($robot);
* }
* </code>
phalcon单独执行select update等sql语句
分享

发表评论

评论 0 条

暂无评论,来说点什么吧。