[英]attempting to modify a field in codeigniter application db table but know how to identify the table
I am beginner in code igniter php framework. 我是代码点火器php框架的初学者。 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 希望有人能帮助我
all_types is your table name. all_types是您的表名。
$this->db->get($your_table name), get method take table name as a parameter. $ this-> db-> get($ your_table name),get方法将表名作为参数。
Get Method Documentation 获取方法文档
If more help needed I'm happy to help. 如果需要更多帮助,我很乐意提供帮助。
Happy Coding . 快乐编码 。
From your model code: 从您的模型代码:
$query=$this->db->get($db);
This means $db
is the table name. 这意味着$db
是表名。 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. 我可以说all_types是表的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.