Zend Framework数据库操作方法实例总结

(编辑:jimmy 日期: 2026/1/29 浏览:2)

本文实例讲述了Zend Framework数据库操作方法。分享给大家供大家参考,具体如下:

示例:

<"Sir"
//   ORDER BY first_name
//   LIMIT 10 OFFSET 20
//
// 你可以使用一种重复定义的方式...
$select->from('round_table', '*');
$select->where('noble_title = "htmlcode">
<"Sir"
//   ORDER BY first_name
//   LIMIT 10 OFFSET 20
//
$select->from('round_table', '*')
  ->where('noble_title = :title')
  ->order('first_name')
  ->limit(10,20);
// 读取结果使用绑定的参数
$params = array('title' => 'Sir');
$result = $db->fetchAll($select, $params);
"htmlcode">
<"htmlcode">
<"htmlcode">
<"Sir"
//   AND favorite_color = "yellow"
//
$select->from('round_table', '*');
$select->where('noble_title = "Sir"'); // embedded value
$select->where('favorite_color = "baz"
//   OR id IN("1", "2", "3")
//
$select->from('foo', '*');
$select->where('bar = "htmlcode">
<"htmlcode">
<"1"
//
$select->from('foo', 'COUNT(id) AS count_id');
$select->group('bar, baz');
$select->having('count_id > "htmlcode">
<"htmlcode">
<"LIMIT :count"
$select = $db->select();
$select->from('foo', '*');
$select->order('id');
$select->limit(10);
//
// 在mysql/psotgreSql/SQLite,可以得到这样的语句:
//
// SELECT * FROM foo
//   ORDER BY id ASC
//   LIMIT 10
//
// 但是在Microsoft SQL下,可以得到这样的语句:
//
// SELECT TOP 10 * FROM FOO
//   ORDER BY id ASC
//
//
// 现在, 是更复杂的 "LIMIT :count OFFSET :offset"方法
$select = $db->select();
$select->from('foo', '*');
$select->order('id');
$select->limit(10, 20);
//
// 在mysql/psotgreSql/SQLite,可以得到这样的语句:
//
// SELECT * FROM foo
//   ORDER BY id ASC
//   LIMIT 10 OFFSET 20
//
// 但是在Microsoft SQL下,由于不支持偏移量功能,可以得到这样sql语句:
//
// SELECT * FROM (
//   SELECT TOP 10 * FROM (
//     SELECT TOP 30 * FROM foo ORDER BY id DESC
//   ) ORDER BY id ASC
// )
//
// Zend_Db_Adapter 可以自动的完成sql语句的动态创建.
//
"htmlcode">
<"_blank" href="https://www.jb51.net/Special/546.htm">Zend FrameWork框架入门教程》、《php优秀开发框架总结》、《Yii框架入门及常用技巧总结》、《ThinkPHP入门教程》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Zend Framework框架的PHP程序设计有所帮助。

一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。