Joh*_*ohn 0 php zend-framework
这是我到目前为止的代码: -
$db = $this->getInvokeArg('bootstrap')->getPluginResource('db')->getDbAdapter();
$sql = "select * from users";
$result = $db->fetchAll($sql);
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>Username</th>
<th>Password</th>
</tr>
";
while($row = mysql_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['password'] . "</td>";
echo "</tr>";
}
echo "</table>";
Run Code Online (Sandbox Code Playgroud)
我正在尝试这个,但我收到了这个错误: -
Warning: mysql_fetch_array() expects parameter 1 to be resource, array given in /var/www/datashow/application/controllers/IndexController.php on line 35
Run Code Online (Sandbox Code Playgroud)
Zend_Db不返回mysql结果对象.在使用Zend_Db抽象层时,您不会使用MySQL的函数; 你使用Zend的功能.在这种情况下,findAll已经将数据作为数组返回.
| 归档时间: |
|
| 查看次数: |
804 次 |
| 最近记录: |