2011-10-04 18:39


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)

Do you? You can trust that all the values are there.

The error is:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE ListingPrice <= '100000' AND ListingPrice >= '0' LIMIT 10' at line 2

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongziche8030 dongziche8030 10年前

    I don't use CodeIgniter but there doesn't seem to be a FROM element to your query

    点赞 评论 复制链接分享
  • dsfdsf46465 dsfdsf46465 10年前

    Looks like you're mixing the MODEL within the CONTROLLER also try using the profiler to get more details on your 'error' => $this->output->enable_profiler(TRUE);

    Otherwise you are missing the FROM:
    $q = $this->db->select('*')->from('TABLE')....

    点赞 评论 复制链接分享
  • dongxing1965 dongxing1965 10年前

    You didn't specify the table you are querying from. Try setting the table name inside the get method or using the from() method somewhere in your query.


    Also, if you are just selecting everything ("*") you can leave out the select() from your query because it will select everything by default.

    点赞 评论 复制链接分享