私は Codeigniter を使い始めたばかりで、これに夢中になっています。ユーザーがプログラムを購入したかどうかを判断するクエリがあります。次に、そのプログラムのタイプ カテゴリを使用して実行し、別のテーブルにクエリを記録した回数を特定する必要があります。混乱して申し訳ありませんが、コードが理にかなっていることを願っています。
モデルからコントローラーへの2つの配列を明らかにビューに返すのに問題があります。
function specificPrograms() {
$specific_sql = $this->db->query("SELECT program,created FROM `assessment` WHERE uid = $this->uid");
if($specific_sql->num_rows() > 0) {
foreach ($specific_sql->result() as $specific) {
$data[] = $specific;
$this->type = $specific->program;
}
return $data;
}
$sub_sql = $this->db->query("SELECT id FROM othertable WHERE user_id_fk = $this->uid and type = '$this->type'");
if($sub_sql->num_rows() > 0) {
foreach ($sub_sql->result() as $otherp) {
$data[] = $otherp;
}
return $data;
}
}
次に、コントローラーに、
$data['specific'] = $this->user_model->specificPrograms();
$data['otherp'] = $this->user_model->specificPrograms();
助けてくれてありがとう。