Welcome Guest, Not a member yet? Register   Sign In
False table prefix in sql select statement
#3

[eluser]Unknown[/eluser]
I've a similar problem

Code:
$select = str_replace('$',$this->db->dbprefix,
            '$purchase.ID, $purchase.price, $purchase.state,
            DATE_FORMAT($purchase.timestamp_created,     "%e.%c.%Y %H:%i:%s") AS timestamp_created,
            DATE_FORMAT($purchase.timestamp_ordered,     "%e.%c.%Y %H:%i:%s") AS timestamp_ordered,
            DATE_FORMAT($purchase.timestamp_confirmed,    "%e.%c.%Y %H:%i:%s") AS timestamp_confirmed,
            (
                SELECT         GROUP_CONCAT($client.name)
                FROM         $client
                WHERE         $purchase.client_ID = $client.ID
            ) AS "client",
            (
                SELECT         GROUP_CONCAT($product.name SEPARATOR \',<br />\')
                FROM         $product
                LEFT JOIN     $purchase_product
                       ON     ($purchase_product.product_ID = $product.ID)
                WHERE         $purchase_product.purchase_ID = $purchase.ID
            ) AS "products"');
        
        $this->db->select($select, false);
        $this->db->from('purchase');
        $this->db->group_by('purchase.ID');
        $this->db->order_by('purchase.timestamp_created','DESC');

produces the following mysql error


Quote:A Database Error Occurred

Error Number: 1064

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 '(kfc_purchase.timestamp_created, "%e %c %Y %H %i") AS timestamp_created, ( SELE' at line 1

SELECT kfc_purchase.ID, kfc_purchase.price, kfc_purchase.state, kfc_DATE_FORMAT(kfc_purchase.timestamp_created, "%e %c %Y %H %i") AS timestamp_created, ( SELECT GROUP_CONCAT(kfc_client.name) FROM kfc_client WHERE kfc_purchase.client_ID = kfc_client.ID ) AS "client", ( SELECT GROUP_CONCAT(kfc_product.name SEPARATOR ',
') FROM kfc_product LEFT JOIN kfc_purchase_product ON (kfc_purchase_product.product_ID = kfc_product.ID) WHERE kfc_purchase_product.purchase_ID = kfc_purchase.ID ) AS "products" FROM (kfc_purchase) GROUP BY kfc_purchase.ID ORDER BY kfc_purchase.timestamp_created DESC

The problem is that CI adds my table prefix to DATE_FORMAT although I set the the second parameter false in "$this->db->select($select, false);"

Is this a bug?


Messages In This Thread
False table prefix in sql select statement - by El Forum - 04-24-2008, 08:43 AM
False table prefix in sql select statement - by El Forum - 04-24-2008, 09:09 AM
False table prefix in sql select statement - by El Forum - 01-25-2009, 03:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB