<pre class="cake-debug">
Array
(
[0] => Array
(
[Qnote] => Array
(
[id] => 67
[subject] => Call Closing
[body] => Gave Information
[user_id] => 39
)
[Step] => Array
(
[0] => Array
(
[id] => 2
[user_id] => 39
[qnote_id] => 67
[type] => a
[body] => This is a text
)
[1] => Array
(
[id] => 3
[user_id] => 39
[qnote_id] => 67
[type] => a
[body] => This is userid 39
)
)
)
中提取信息)從Array
您好,我想從這個數組
<?php foreach($data as $qnote): ?>
<?php echo $qnote['Qnote']['id']; ?> // Works
<?php echo $qnote['Qnote']['body']; ?> //Works
<?php echo $qnote['Step']['body']; ?> // Doesnt Work ????
<?php endforeach; ?>
什麼拉起步數據以正確的方式提取數據。 有人請指點我正確的方向。
控制器代碼:
function view($id = null) {
$this->Qnote->id = $id;
$userID = $this->Authsome->get('id');
$this->paginate = array(
'conditions' => array(
'Qnote.id LIKE' => $id),
);
$data = $this->paginate('Qnote');
$this->set('data', $data);
}
BTW,沒有必要' 'Qnote.id LIKE'=> $ id'。 SQL'LIKE'比較比直接比較'='要慢很多,而且一個數字只能是一個數字。擺脫'LIKE'。 – deceze 2011-05-05 10:21:31