Welcome Guest, Not a member yet? Register   Sign In
sql shorthand not working for me
#1

[eluser]battlemidget[/eluser]
Code:
function get_product_by_id($id)
    {
      $this->db->select('product.*')->from('product')->where('product.id', $id);
      $query = $this->db->get();
      return $query->result();
    }

error:
Code:
A Database Error Occurred
Error Number: 1054

Unknown column 'product.*' in 'field list'

SELECT `product`.`*` FROM (`product`) WHERE `product`.`id` = '440'

sql:
Code:
mysql> select product.* from product where product.id = '440';
+-----+-------------+---------------------------------+-------------------------------+-------------------------------------+-------+----------+
| id  | category_id | description                     | image_name                    | image_thumb                         | price | in_stock |
+-----+-------------+---------------------------------+-------------------------------+-------------------------------------+-------+----------+
| 440 | 12          | Cable Neck Button Seater - Gray | Cable Neck Button Sweater.JPG | Cable Neck Button Sweater_thumb.JPG | 48.00 | TRUE     |
+-----+-------------+---------------------------------+-------------------------------+-------------------------------------+-------+----------+


What exactly am i doing wrong?

$ pacman -Q mysql apache php
mysql 5.1.38-1
apache 2.2.13-2
php 5.3.0-3

CI 1.7.2

EDIT:

I've also done this very same thing on another CI project and it worked:

Code:
function getPropertyBySearch($loc, $p_start, $p_end, $bed)
    {
        // build join query for items above
        // give us a good clean interface for
        // customers to browse through
        $this->db->select('properties.*, locations.id as lid');
        $this->db->from('properties');
        $this->db->where('location_id',$loc);
        $this->db->where('properties.bedroom',$bed);
        $this->db->where('properties.rent >=', $p_start);
        $this->db->or_where('properties.rent <=', $p_end);
        $this->db->join('locations', 'locations.id = properties.location_id');
        $query = $this->db->get();

        return $query->result();
    }

All settings are the same and both run on virtual ips on same box.


Messages In This Thread
sql shorthand not working for me - by El Forum - 09-23-2009, 12:53 PM
sql shorthand not working for me - by El Forum - 09-23-2009, 01:28 PM
sql shorthand not working for me - by El Forum - 09-23-2009, 01:30 PM
sql shorthand not working for me - by El Forum - 09-23-2009, 01:36 PM
sql shorthand not working for me - by El Forum - 09-23-2009, 02:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB