Error Number: 1054 - Unknown column '2' in 'field list' |
[eluser]Nexus Rex[/eluser]
An integer in my active record query is being mistaken for a column. I am using the POWER function in mySQL, and the power of 2 is being mistaken for a column called 2. Here is my code: Code: $this->db->select('DISTINCT locations.id, locations.location_number, locations.name, locations.street_address, locations.street_address_line2, locations.city, locations.state_province, locations.zip_postal_code, locations.country, locations.phone, locations.toll_free, locations.fax, locations.email, locations.website_url, locations.contact_name, locations.contact_title, locations.additional_info, locations.image, us_ca_codes.latitude, us_ca_codes.longitude, (3956 * 2 * ASIN(SQRT( POWER(SIN((' . $mylocal->point->latitude . ' - us_ca_codes.latitude) * pi()/180 / 2), 2) + COS(' . $mylocal->point->latitude . ' * pi()/180) * COS(us_ca_codes.latitude * pi()/180) * POWER(SIN((' . $mylocal->point->longitude . ' - us_ca_codes.longitude) * pi()/180 / 2), 2) )) ) AS distance'); Here is my error: Code: A Database Error Occurred Any thoughts?
[eluser]Derek Allard[/eluser]
What happens if you add FALSE as a second parameter? You can read more about it at http://ellislab.com/codeigniter/user-gui...tml#select
|
Welcome Guest, Not a member yet? Register Sign In |