Php 未执行Codeigniter Mysql查询

Php 未执行Codeigniter Mysql查询,php,mysql,codeigniter,Php,Mysql,Codeigniter,我想制作一个简单的搜索引擎,从数据库中查找数据并显示出来,但我不明白为什么要执行这些查询。下面是我的代码: 模型页 当我从搜索表单执行搜索时,我得到的结果是没有!,有人能帮我吗,因为我已经尝试过很多次了,我不是一个专业的网络开发者,我只是在学习,谢谢所有的贡献者 $this->db->like('sReference', $match); $this->db->like('nReference', $match); $this->db->or_like('sS

我想制作一个简单的搜索引擎,从数据库中查找数据并显示出来,但我不明白为什么要执行这些查询。下面是我的代码:

模型页 当我从搜索表单执行搜索时,我得到的结果是没有!,有人能帮我吗,因为我已经尝试过很多次了,我不是一个专业的网络开发者,我只是在学习,谢谢所有的贡献者

$this->db->like('sReference', $match);
$this->db->like('nReference', $match);
$this->db->or_like('sSearch', $match);
这部分呢

$this->db->from('treference', $match);
换成

$this->db->from('treference');
试试这个


希望对您有所帮助。

型号:

    class Reference_model extends CI_Model
    {


        function search($match)
        {
            $this->db->select('*');   //this line
            $this->db->where('sReference', $match);
            $this->db->like('nReference', $match);
            $this->db->or_like('sSearch', $match);
            $this->db->from('treference');  //this line
            $query = $this->db->get();

                if($query->num_rows > 0){
                    $output = '<ul>';
                    foreach ($query->result() as $rows){
                        $output .= '<li>'.$rows->nReference.'</li>';
                    }
                    $output .='</ul>';
                }else{
                    return "<p>No Results!</p>"; //No Results!
                }
                return $output;
        }
    }
类引用模型扩展了CI模型 { 函数搜索($match) { $this->db->select('*');//此行 $this->db->where('sReference',$match); $this->db->like('nReference',$match); $this->db->or_like('sSearch',$match); $this->db->from('treference');//此行 $query=$this->db->get(); 如果($query->num\u rows>0){ $output='
    '; foreach($query->result()作为$rows){ $output.='
  • '.$rows->nReference.
  • '; } $output.='
'; }否则{ 返回“无结果!

”;//无结果! } 返回$output; } } 尝试使用echo/print\recho$this->db->last\u query()调试查询

希望这对您有所帮助。

更改此选项

if($query->num_rows > 0){

num_行
应该是一个函数。 如果仍然不起作用。 尝试转储正在生成的查询并将其发布到此处

var_dump($this->db->last_query()); die('x'); if($query->num_rows > 0){

检查查询的依据是什么$这个->数据库->最后一个查询()我相信应该这样做。他还有一个问题,没有人提到,那就是他的查询行的顺序。我认为订单需要从上到下,从顶部的
select
行开始
if($query->num_rows > 0){
if($query->num_rows() > 0){
var_dump($this->db->last_query()); die('x'); if($query->num_rows > 0){