ahkxhyl
发表于 2010-9-8 17:04:49
不行还是报Fatal error: Call to a member function result_array() on a non-object in 错误
sonic
发表于 2010-9-8 17:07:16
你其他数据库的查询可以做吗?
ahkxhyl
发表于 2010-9-8 17:09:29
其他没错 就这个
sonic
发表于 2010-9-8 17:13:01
整形照道理不用加单引号的再SQL语句中
ahkxhyl
发表于 2010-9-8 17:17:28
我去掉了单引号 还是报错
sonic
发表于 2010-9-8 17:24:12
把你的建表语句拿来看看
show create table table_name;
ahkxhyl
发表于 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');
sonic
发表于 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 |
------------+---------------------------------------------
我想帮你重写这个方法看看能不能用;
就是说我想看你的表结构
ahkxhyl
发表于 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;
sonic
发表于 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();
}
}
?>