CodeIgniter Forums
SQL functions on DB class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: SQL functions on DB class (/thread-68680.html)



SQL functions on DB class - tibon - 08-11-2017

Hello,

Is there a way to run SQL function with the CI db class?(ie: COMPRESS(?))

In slim framework I'm using it in this way:


PHP Code:
$data = array(
       "userid" => $userid,
      "data" => $this->db->func('COMPRESS(?)', [json_encode($data)]),
);

 $db_insert $this->db->insert("products"$data); 

Is there something similar in CI?

Thanks! Smile


RE: SQL functions on DB class - tibon - 08-12-2017

An update:
Ended up with converting the insert to query binds. Hopefully it'll help someone in the future.


RE: SQL functions on DB class - Project404 - 08-12-2017

Depending on the version of CI you are using this might help you out: https://codeigniter.com/user_guide/database/call_function.html


RE: SQL functions on DB class - skunkbad - 08-12-2017

Maybe:


PHP Code:
$this->db->query('COMPRESS(?)'data);