dtgr3392
dtgr3392
2017-03-30 10:52
浏览 39
已采纳

尝试修改codeigniter应用程序db表中的字段,但知道如何识别表

I am beginner in code igniter php framework. Today I have a task to modify existing code and somehow I am lost in the middle of the line on attempting to located a database table. This is the controller snippet that renders the view

..........
$data["all_types"] = $this->data_model->get_data("all_types",300,"Asc");
$this->load->view("preview_brands",$data);
...........

when the view is loaded I am iterating through the in the view to load data as shown

 <div class="decoration"></div>
 <?php foreach($all_types as $item): ?>
 <div style="display:block;color:#000;">
    <a style="font-size:17px;margin:15px 2px;font-family:Cgothic;"
                           href="<?php echo site_url()."...../..../".$item["id"]; ?>"
                           class="scale-hover"
                           title="<?php echo str_replace("_"," ",$item["name"]);?>">
    <strong><?php echo str_replace("_"," ",$item["name"]);?></strong>
    </a>

 </div>             
 <?php endforeach; ?>

this is the model snippet code as shown

function get_data($db,$i,$order)
{
   $this->db->order_by("name",$order);
   $this->db->where('consent',"yes");
   $query=$this->db->get($db);
   return $query->result_array();
}

My challenge is how can I locate or identify the database table the above model is pointing to to fetch data. Hoping someone assists me

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douou8954
    douou8954 2017-03-30 11:14
    已采纳

    all_types is your table name.

    $this->db->get($your_table name), get method take table name as a parameter.

    Get Method Documentation

    If more help needed I'm happy to help.

    Happy Coding.

    点赞 评论
  • douqinlin5094
    douqinlin5094 2017-03-30 11:14

    From your model code:

    $query=$this->db->get($db);
    

    This means $db is the table name. Looking at your controller code which calls the model function:

    $data["all_types"] = $this->data_model->get_data("all_types",300,"Asc");
    

    I can say that all_types is the name of the table.

    点赞 评论

相关推荐