Я создал две таблицы, такие как «iv_mail» и «iv_mail_subfeatures». Первая таблица «iv_mail» включала в себя поля «имя», «электронная почта», «телефон», «имя функции» и т. Д., А «iv_mail_subfeatures» содержит подфункции каждой функции, я ставлю запрос, используя получить значения из двух таблиц. на самом деле мне нужны подфункции соответствующих функций как показано ниже, я использовал этот запрос,
модель
public function getmailfeatures($id)
{
$this->db->where('id',$id);
$query = $this->db->get('iv_mail');
$return=array();
foreach($query->result() as $getlist)
{
$return[$getlist->id]=$getlist;
$subfeature_id= explode(',',$getlist->featurename);
foreach($subfeature_id as $subfea)
{
$feature_id=substr($subfea,0,1);
$return[$getlist->id]->subfeatures[]=$this->get_sub_features($id);
}
}
return $return;
}
public function get_sub_features($id)
{
$this->db->select('*');
$this->db->where('customer_id',$id);
$query = $this->db->get('iv_mail_subfeatures');
return $query->result();
}
Контроллер
public function maildetails()
{
$id=$this->uri->segment(3);
$data['featuresdetails']=$this->Feature_model->getmailfeatures($id);
$this->load->view('admin/mail/mail_details',$data);
}
вид
<p>Features</p>
<?php
foreach($featuresdetails as $feature)
{
echo $feature->featurename ;
foreach($feature->subfeatures as $sub)
{
$new_array = objectToArray($sub);
echo"<pre>";
print_r( $new_array);
foreach( $new_array as $new)
{
}
}
}
?>
получит два массива. Я не могу напечатать значения, которые мне могут помочь.
(
[0] => Array
(
[id] => 1
[feature_id] => 1
[customer_id] => 1
[subfeaturename] => 1_a/c
)
[1] => Array
(
[id] => 2
[feature_id] => 1
[customer_id] => 1
[subfeaturename] => 1_non a/c
)
[2] => Array
(
[id] => 3
[feature_id] => 2
[customer_id] => 1
[subfeaturename] => 2_surya caters
)
[3] => Array
(
[id] => 4
[feature_id] => 2
[customer_id] => 1
[subfeaturename] => 2_test caters
)
[4] => Array
(
[id] => 5
[feature_id] => 2
[customer_id] => 1
[subfeaturename] => 2_dd caters
))
Array
(
[0] => Массив
(
[id] => 1
[feature_id] => 1
[customer_id] => 1
[subfeaturename] => 1_a / c
)
[1] => Array
(
[id] => 2
[feature_id] => 1
[customer_id] => 1
[subfeaturename] => 1_non a/c
)
[2] => Array
(
[id] => 3
[feature_id] => 2
[customer_id] => 1
[subfeaturename] => 2_surya caters
)
[3] => Array
(
[id] => 4
[feature_id] => 2
[customer_id] => 1
[subfeaturename] => 2_test caters
)
[4] => Array
(
[id] => 5
[feature_id] => 2
[customer_id] => 1
[subfeaturename] => 2_dd caters
)
)