public $belongsTo = array(
'Hospital' => array(
'className' => 'Hospital',
'foreignKey' => 'hospital_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
public $hasMany = array(
'Floor' => array(
'className' => 'Floor',
'foreignKey' => 'hospital_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);我有两个表医院和楼层,我已经从医院表检索数据,并显示在楼层视图在添加楼层。
发布于 2013-09-17 13:55:03
您已经设置了关系,所以现在只需要创建一个控制器操作和一个视图。
假设您的表已经就位,最简单的方法就是在医院模型上运行cake bake all,它将为您生成视图。Cake足够智能,可以生成一个视图,该视图将显示相关楼层的列表,如果这是您想要的(从您的帖子中看不清楚)。
发布于 2013-09-17 13:35:58
您可以像这样从数据库中检索数据...
mysql_select_db("users"); //your database name
$sql = mysql_query("SELECT * FROM langs"); //table name
$limit = 4;
$count = 3;
echo "<table border='1'>";
while($row = mysql_fetch_array($sql)){
$name=$row['name'];
$email=$row['email'];
$contact=$row['contact'];
if($count < $limit){
echo "<tr>";
}
............. //you can put in table and in any other field
?>https://stackoverflow.com/questions/18841775
复制相似问题