php - 发送 codeIgniter result_array 以在视图中访问
问题描述
当我加载 codeIgniter 文件时,我使用 print_r 获得的结果不会发送到视图文件。请帮忙?
模型
class Tether extends CI_Model {
public $table='';
public $primary_key='';
public function fetch_data(){
$this->db->select('*');
$this->db->from($this->table);
$this->db->order_by($this->primary_key,'desc');
return $this->db->get()->result_array();
}
控制器
public function index(){
$task=new Tether;
$task->table=$this->table;
$query=$task->fetch_data();
print_r($query);
$this->load->view('layout_chart',$query);
print_r 结果是:
Array ( [0] => Array ( [trend_id] => 1 [month] => JANUARY [year] => 2015 [amount] => 10000 ) [1] => Array ( [trend_id] => 2 [month] => FEBRUARY [year] => 2015 [amount] => 15000) [2] => 数组 ([trend_id] => 3 [month] => MARCH [year] => 2015 [amount] => 20000)
解决方案
控制器:
$query['result'] = $task->fetch_data();
在 layout_chart 视图中:
print_r($result);
推荐阅读
- angular - Primeng Autocomplete - 不使用 Angular 中的反应形式修补值
- elasticsearch - Filebeat 缓冲区控制
- tomcat - 如何将流量从 Nginx 入口路由到应用程序 Tomcat 服务器
- jmeter - 使用 Jmeter 连接雪花 JDBC 连接器时收到错误
- r - 识别事件前后的行
- java - 如何在数据库连接中正确使用 try-with-resources?
- firebase - 谷歌云功能:无法加载默认凭据
- weblogic - com.oracle.weblogic.lifecycle.core.PartitionLCMService 错误
- php - Eloquent Query Builder 中的 Laravel 分页
- javascript - 编辑列表中的元素