Php CodeIgniter数据库查询有一个错误,但我没有看到它

Php CodeIgniter数据库查询有一个错误,但我没有看到它,php,mysql,codeigniter,Php,Mysql,Codeigniter,你知道吗?您可以相信所有的值都存在 错误是: 您的SQL语法有错误;查看与MySQL服务器版本对应的手册,以了解第2行“WHERE ListingPrice='0'LIMIT 10'附近要使用的正确语法 您没有指定要从中查询的表。尝试在get方法内设置表名,或在查询中的某个位置使用from方法 if ($this->input->get('beds')) $where['Bedrooms'] = $this->input->get('beds'); if ($

你知道吗?您可以相信所有的值都存在

错误是:


您的SQL语法有错误;查看与MySQL服务器版本对应的手册,以了解第2行“WHERE ListingPrice='0'LIMIT 10'附近要使用的正确语法


您没有指定要从中查询的表。尝试在get方法内设置表名,或在查询中的某个位置使用from方法

if ($this->input->get('beds')) 
    $where['Bedrooms'] = $this->input->get('beds');

if ($this->input->get('baths'))
    $where['Bathrooms'] = $this->input->get('baths');

$min_price = ($this->input->get('min_price')) 
    ? $this->input->get('min_price')
    : '0';

$max_price = ($this->input->get('max_price'))
    ? $this->input->get('max_price')
    : '10000000';

$q = $this->db->select("*")
    ->where('ListingPrice <=', $max_price)
    ->where('ListingPrice >=', $min_price)
    ->limit(10)
    ->get();  

另外,如果您只是选择了所有内容*,则可以从查询中省去select,因为默认情况下它会选择所有内容。

您没有指定要从中查询的表。尝试在get方法内设置表名,或在查询中的某个位置使用from方法

if ($this->input->get('beds')) 
    $where['Bedrooms'] = $this->input->get('beds');

if ($this->input->get('baths'))
    $where['Bathrooms'] = $this->input->get('baths');

$min_price = ($this->input->get('min_price')) 
    ? $this->input->get('min_price')
    : '0';

$max_price = ($this->input->get('max_price'))
    ? $this->input->get('max_price')
    : '10000000';

$q = $this->db->select("*")
    ->where('ListingPrice <=', $max_price)
    ->where('ListingPrice >=', $min_price)
    ->limit(10)
    ->get();  

此外,如果您只是选择了所有内容*,您可以从查询中省去select,因为它将在默认情况下选择所有内容。

看起来您正在控制器中混合模型,还可以尝试使用探查器获取有关“错误”的更多详细信息=>$this->output->enable_profilerTRUE

否则,您将丢失以下信息:
$q=$this->db->select'*'->from'TABLE'..

看起来您正在控制器中混合模型,还可以尝试使用探查器获取有关“error”的更多详细信息=>$this->output->enable_profilerTRUE

否则,您将丢失以下信息:
$q=$this->db->select'*'->from'TABLE'..

我没有使用CodeIgniter,但查询中似乎没有from元素

我没有使用CodeIgniter,但查询中似乎没有from元素

那么,您收到了什么错误消息?什么不起作用了?我没有使用CodeIgniter,但是你的查询中似乎没有FROM元素你的SQL语法有错误;查看与MySQL服务器版本对应的手册,了解第2Clive行“WHERE ListingPrice='0'LIMIT 10'附近要使用的正确语法,将该答案作为实际答案给出,我将接受。啊!你是对的,你收到了什么错误信息?什么不起作用了?我没有使用CodeIgniter,但是你的查询中似乎没有FROM元素你的SQL语法有错误;查看与MySQL服务器版本对应的手册,了解第2Clive行“WHERE ListingPrice='0'LIMIT 10'附近要使用的正确语法,将该答案作为实际答案给出,我将接受。啊!你是对的。