CodeIgniter 2.1.4 model 得不到数据库数据 model db 类无 result_array()方法
来源:互联网 发布:mfc编程实例 pdf 编辑:程序博客网 时间:2024/06/04 18:13
为了尝鲜,在 ci 中国社区下载了2.1.4的版本,因为 en 文读起来还是略微费劲.
所以在中国社区版的 online 文档里找了几个例子先尝试下.
但随后问题就来了.
配置完数据库、建立模型后,ci 可以连接数据库但确无法读取数据,也未报错。
几番尝试,因例子是社区文档里直接复制过来的,应不会有错。
但程序走到这里确实停了,
public function gets_news($slug = FALSE) {if ($slug == FALSE) {$query = $this->db->get ( 'news' );return $query->result_array ();}$query = $this->db->get_where ( 'news', array ('slug' => $slug) );return $query->row_array ();}
便想到是版本的问题,在 ci 中文社区里找了个2.1.1版本,一试果然成功,那么毫无疑问的是版本问题了,那么问题在哪呢。
最后,在 model 里写了这个方法:
public function getMethodsList() {$class_methods = get_class_methods ( $this->db );foreach ( $class_methods as $method_name ) {echo "$method_name" . "</br>";}}
查找了下,果然没有例子里的result_array()和 row_array()方法,再翻过头来看2.1.4原包里的 user_guide 里面关于 model 一节,果然改变了用法,因此上面的查询方法改成如下:
public function get_news($slug = FALSE) {if ($slug == FALSE) {$query = $this->db->get ( 'news' );$result = $query->result ();return $result;}$query = $this->db->get_where ( 'news', array ('slug' => $slug) );return $query->result ();}
0 0
- CodeIgniter 2.1.4 model 得不到数据库数据 model db 类无 result_array()方法
- CodeIgniter Model
- 具体的数据库操作类,Model类和DB类
- codeigniter源代码分析 - 模型类 Model.php
- django model 插入数据方法
- django model 插入数据方法
- model 数据库
- Solar Model数据库操作之读取数据
- Solar Model数据库操作之添加数据
- Solar Model数据库操作之修改数据
- Solar Model数据库操作之删除数据
- QML使用数据库存储Model数据
- Yii model进行数据库数据更新
- db.model base 的区别
- CodeIgniter 一个Model中调用另一个Model的问题
- 得不到数据库中的数据
- thinkphp Model类方法一览
- thinkphp Model类方法一览
- CString转int
- datastation
- 【STL】插入型迭代器(Insert Iterator)或插入器(inserter)
- Cocos2D-X2.2.3学习笔记3(内存管理)
- MapReduce原理浅析(转)
- CodeIgniter 2.1.4 model 得不到数据库数据 model db 类无 result_array()方法
- 捕获Entity framework验证异常
- Lua的upvalue和闭包
- PAT A 1013. Battle Over Cities (25)
- kill 进程
- aix6.1上安装10g r2注意事项
- 文件系统的过滤
- WAS8.5(websphere application server)安装记录
- 乱、乱、乱,思绪乱!方向乱!