Welcome Guest, Not a member yet? Register   Sign In
Problem with active records
#1

[eluser]Unknown[/eluser]
Hello! I've just started using CodeIgniter and found it surprisingly easy to use (I switched from ZF). Now I have ran into my first problem, which has to do with Active records (which I haven't used before)

I have a function that looks like this:
Code:
function get_top_rated_movies($limit_num_of_movies) {
            $this->db->select("title, TRUNCATE((rating_acting+rating_dvd+rating_overall)/3, 1) as avg_rating");
            $this->db->order_by("avg_rating", "DESC");
            $this->db->limit($limit_num_of_movies);
            $query = $this->db->get();

            return $query;
        }

This will return an error:
Quote: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 'as avg_rating FROM (`dvd_collection`) ORDER BY `avg_rating` DESC LIMIT 20' at line 1

SELECT `title`, TRUNCATE((rating_acting+rating_dvd+rating_overall)/3, `1)` as avg_rating FROM (`dvd_collection`) ORDER BY `avg_rating` DESC LIMIT 20

For some reason it encloses 1) with singular quotation-marks. Is there something I have missed here? It's seems very odd to me.

(Sorry if my language seems to be a bit off, I'm from Sweden)


Messages In This Thread
Problem with active records - by El Forum - 06-10-2010, 05:40 PM
Problem with active records - by El Forum - 06-11-2010, 12:18 AM
Problem with active records - by El Forum - 06-11-2010, 02:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB