用户
 找回密码
 入住 CI 中国社区
搜索
楼主: ahkxhyl
收起左侧

[HELP] 急!求助CI高手

[复制链接]
 楼主| 发表于 2010-9-8 17:04:49 | 显示全部楼层
不行还是报Fatal error: Call to a member function result_array() on a non-object in 错误
发表于 2010-9-8 17:07:16 | 显示全部楼层
你其他数据库的查询可以做吗?
 楼主| 发表于 2010-9-8 17:09:29 | 显示全部楼层
其他没错 就这个
发表于 2010-9-8 17:13:01 | 显示全部楼层
整形照道理不用加单引号的再SQL语句中
 楼主| 发表于 2010-9-8 17:17:28 | 显示全部楼层
我去掉了单引号 还是报错
发表于 2010-9-8 17:24:12 | 显示全部楼层
把你的建表语句拿来看看
show create table table_name;
 楼主| 发表于 2010-9-8 17:29:17 | 显示全部楼层
-- Records of category
-- ----------------------------
INSERT INTO `category` VALUES ('1', 'Company Information', '0', '', null, '1', '2010-08-06');
INSERT INTO `category` VALUES ('2', 'Stock Information', '0', '', null, '1', '2010-08-06');
INSERT INTO `category` VALUES ('3', 'Financial Reports', '0', '', null, '1', '2010-08-06');
INSERT INTO `category` VALUES ('4', 'Corporate Governance', '0', '', null, '1', '2010-08-06');
发表于 2010-9-8 17:35:29 | 显示全部楼层
为啥我命令行出来这种东西
categories | CREATE TABLE `categories` (
`categories_id` int(11) NOT NULL AUTO_INCREMENT,
`parent_id` int(11) NOT NULL,
`categories_name` varchar(255) DEFAULT NULL,
`categories_image` varchar(255) DEFAULT NULL,
`categories_description` text,
`sort_order` int(11) DEFAULT NULL,
`created` datetime DEFAULT NULL,
PRIMARY KEY (`categories_id`)
ENGINE=MyISAM AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 |
------------+---------------------------------------------
我想帮你重写这个方法看看能不能用;
就是说我想看你的表结构
 楼主| 发表于 2010-9-8 17:49:03 | 显示全部楼层
CREATE TABLE `category` (
  `Id` int(11) NOT NULL auto_increment,
  `name` varchar(50) default NULL,
  `category` int(11) default NULL COMMENT '表示一级栏目,出境游或国内游或周边游等等',
  `intro` text,
  `px` int(11) default NULL COMMENT '排序',
  `gd` tinyint(1) default NULL,
  `addtime` date default NULL,
  PRIMARY KEY  (`Id`)
) ENGINE=MyISAM AUTO_INCREMENT=31 DEFAULT CHARSET=utf8;
发表于 2010-9-9 06:21:09 | 显示全部楼层
怎么看你的数据
都是category=0的行呢?
所以我觉得参数的话,用0才对
<?php
class Category extends Controller{
        function Category(){
                parent::Controller();
                $this->load->model('cate_model');
               
        }
        function cate_list()
        {
                $arr=$this->cate_model->get_all_cate(0);
                print_r($arr);
                exit();
               
        }
}
?>

<?php
class cate_model extends Model{
        function get_all_cate($category)
        {
                $sql="select id,name from category
                where category=?
                order by id desc";
                $res=$this->db->query($sql,$category);
                return $res->result_array();
               
        }
}
?>

本版积分规则