#1 spitcold
function getLessonUrlsById(){$lessonId = $this->spArgs('lessonId');
$Lesson=spDB("xuexi11_lesson");
$result=$Lesson->find('id',$lessonId);
header("Content-type: text/plain; charset=utf-8");
echo $tmp_jiami;
}
运行结果老不能显示正常的记录。在spModel中设置一个echo:
public function findAll($conditions = null, $sort = null, $fields = null, $limit = null)
{
$where = "";
$fields = empty($fields) ? "*" : $fields;
if(is_array($conditions)){
$join = array();
foreach( $conditions as $key => $condition ){
$condition = $this->escape($condition);
$join[] = "{$key} = {$condition}";
}
$where = "WHERE ".join(" AND ",$join);
}else{
if(null != $conditions)$where = "WHERE ".$conditions;
}
if(null != $sort){
$sort = "ORDER BY {$sort}";
}else{
$sort = "ORDER BY {$this->pk}";
}
$sql = "SELECT {$fields} FROM {$this->tbl_name} {$where} {$sort}";
if(null != $limit)$sql = $this->_db->setlimit($sql, $limit);
echo 'spModel-->'.$sql.'
';
return $this->_db->getArray($sql);
}
访问:http://localhost/index.php?c=conLesson&a=getLessonUrlsById&lessonId=3
显示的查询语句sql: spModel-->SELECT * FROM xuexi11_lesson WHERE id ORDER BY 3 LIMIT 1
为什么where id order by 3 呢?是不是我弄错了,还是框架拼装sql时出问题呀。
求救啊
2011-06-24 14:44:27