配列 $added_tabs を持つコントローラーがあります。この配列を関数モデルに渡します。私のモデルでは、結果を印刷するとすべて正常に動作しますが、コントローラーに $row を再度返すと、1 つのレコードのみが表示されます。
何か案は?
私のコントローラーにはこれがあります:
$this->load->model('check_info/check_post_day');
$admin_post_day = $this->check_post_day->check_post($added_tabs);
echo "<pre>"; print_r($admin_post_day); echo "</pre>";
私のモデルでは、これがあります:
class Check_post_day extends CI_Model {
function check_post($data) {
foreach ($data as $info) {
$row = array();
$query = $this->db->query("
SELECT
admin_post_day.page_id,
admin_post_day.admin_id,
admin_post_day.hour_post,
admin_post_day.discount,
admin_post_day.url,
admin_post_day.message_post,
admin_post_day.voucher,
admin_post_day.date_saved,
fb_pages.page_id,
fb_pages.id_fb_pages,
fb_pages_admin.access_token
FROM admin_post_day
inner join fb_pages
on admin_post_day.page_id=fb_pages.page_id
inner join fb_pages_admin
on fb_pages.id_fb_pages=fb_pages_admin.id_fb_pages
where admin_post_day.page_id LIKE " . $info['page_id'] . "
ORDER BY admin_post_day.date_saved DESC LIMIT 1
");
foreach ($query->result_array() as $row) {
$info = $row;
}
if ( !empty( $query ) ) {
return $row;
} else {
return false;
}
}
}
}
//更新
class Check_post_day extends CI_Model {
function check_post($data) {
foreach ($data as $info) {
$row = array();
$query = $this->db->query("
SELECT
admin_post_day.page_id,
admin_post_day.admin_id,
admin_post_day.hour_post,
admin_post_day.discount,
admin_post_day.url,
admin_post_day.message_post,
admin_post_day.voucher,
admin_post_day.date_saved,
fb_pages.page_id,
fb_pages.id_fb_pages,
fb_pages_admin.access_token
FROM admin_post_day
inner join fb_pages
on admin_post_day.page_id=fb_pages.page_id
inner join fb_pages_admin
on fb_pages.id_fb_pages=fb_pages_admin.id_fb_pages
where admin_post_day.page_id LIKE " . $info['page_id'] . "
ORDER BY admin_post_day.date_saved DESC LIMIT 1
");
if($query->num_rows() > 0){
$rows[] = $query->result_array();
}
}
return $rows;
}
}