网络编程 
首页 > 网络编程 > 浏览文章

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

(编辑:jimmy 日期: 2025/4/20 浏览:3 次 )

本文实例讲述了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程序设计有所帮助。

上一篇:解决微信授权回调页面域名只能设置一个的问题
下一篇:smarty模板数学运算示例
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。