Php 获取CodeIgniter中一行的值

Php 获取CodeIgniter中一行的值,php,codeigniter,Php,Codeigniter,我试图获取数据库中某一行的值,但结果不是很好。我不确定你是否能像这样工作 我只是想从组配置和键中获取值,但也要确保它 型号 function getTitle() { return $this->db->get('setting', array( ->where('group' => 'config'), ->where('key' => 'config_meta_title'), ->where('value'=> )

我试图获取数据库中某一行的值,但结果不是很好。我不确定你是否能像这样工作

我只是想从组配置和键中获取值,但也要确保它

型号

function getTitle() {
  return $this->db->get('setting', array(
    ->where('group' => 'config'),
    ->where('key' => 'config_meta_title'),
    ->where('value'=> ) // Want to be able to return any thing in the value
  ))->row();
}
function getTitle($value) {
   $this->db->select($value);
   $this->db->where("group","config");
   $this->db->where("key","config_meta_title");
   $query = $this->db->get('setting');
   return $query->row()->$value;
}
在控制器中,我将执行以下操作:

function index() {
  $data['title'] = $this->document->getTitle();
  $this->load->view('sample', $data);
}

首先,将此行设置为:

$data['title'] $this->document->getTitle();
这应该是
$this->document->getTitle()的
=
赋值如下所示:

$data['title'] = $this->document->getTitle();
但是,在函数中,您应该实际使用
row()->setting
返回查询中的
设置值:

function getTitle() {
  return $this->db->get('setting', array(
    ->where('group' => 'config'),
    ->where('key' => 'config_meta_title'),
    ->where('value'=> ) // Should return this row information but can not.
  ))->row()->setting;
}
但尽管如此,我对此并不清楚:

->where('value'=> ) // Should return this row information but can not.

A
其中
条件不是
选择
。这是一个连接到
选择
的条件,允许您
选择符合条件的特定值
。所以应该设置为某个值,但不确定是什么,因为您的代码没有提供太多细节。

发现解决方案现在可以工作了。用于从Codeigniter中的数据库中获取单个项目

在库中加载

function getTitle($value) {
   $this->CI->db->select($value);
   $this->CI->db->where("group","config");
   $this->CI->db->where("key","config_meta_title");
   $query = $this->CI->db->get('setting');
   return $query->row()->$value;
}
或在模型中加载

function getTitle() {
  return $this->db->get('setting', array(
    ->where('group' => 'config'),
    ->where('key' => 'config_meta_title'),
    ->where('value'=> ) // Want to be able to return any thing in the value
  ))->row();
}
function getTitle($value) {
   $this->db->select($value);
   $this->db->where("group","config");
   $this->db->where("key","config_meta_title");
   $query = $this->db->get('setting');
   return $query->row()->$value;
}

可能的重复我只需要获取值我怎么做,但仍然有group和keyIn您的第二个代码块您输入错误的函数->函数我应该把什么放在值的位置才能获取其中的内容只有“我应该把什么放在值的位置才能获取其中的内容”数据库中要检查的任何值。你知道这个值是什么吗?如果我这样做->选择('value')并删除这个“=>”,应该会返回该列中的内容。