每当我在模型中使用 get_where 时,它都会给我所有数据库条目,包括重复项,而当我仅使用 get 时,它只会给我第一个条目。但我想要所有不同的条目。任何人都可以帮助我吗?多谢!
控制器=site.php:
public function western_australia(){
$this->load->model("continents_get");
$data["results"] = $this->continents_get
->getMaincategories("western_australia");
$this->load->view("content_western_australia", $data);
}
模型 = Continents_get.php
function getMaincategories($western_australia){
$this->db->distinct();
$query = $this->db->get_where("p_maincategories",
array("page" => $western_australia));
return $query->result();
}
视图= content_western_australia.php
<?php
foreach($results as $row){
$page = $row->page;
$main_en = $row->main_en;
echo $main_en;
?>
独特并不总是有效。你应该添加 ->group_by("name_of_the_column_which_needs_to_be unique");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)