这里简单举例下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>