#1 huangyang0924
2个modelclass topic extends spModel{
public $pk = "tid"; // 每个留言唯一的标志,可以称为主键
public $table = "topics"; // 数据表的名称
var $linker=array(
array(
"type"=>"hasone",
"map"=>"t_uname",
"mapkey"=>"uid",
"fclass"=>"user",
"fkey"=>"uid",
"enabled"=>true
)
);
}
class user extends spModel{
public $pk = "uid";
public $table = "users";
}
控制器中的action为
$topic=spClass("topic");
$fid=$this->spArgs("fid");
$conditions=array("fid"=>$fid);
dump($topic->spLinker()->findall($conditions));
查询结果里为何没有 users表中的字段
Array
(
[0] => Array
(
[tid] => 1
[fid] => 2
[uid] => 1
[title] => 标题1
[content] => 内容1
)
[1] => Array
(
[tid] => 2
[fid] => 2
[uid] => 1
[title] => 标题2
[content] => 内容什么
内容啊
)
[2] => Array
(
[tid] => 6
[fid] => 2
[uid] => 2
[title] => 发新帖
[content] => 神马东西啊
啊吧才
)
)
2010-12-17 14:58:01