Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 1 | ##################### |
| 2 | Custom Function Calls |
| 3 | ##################### |
| 4 | |
| 5 | $this->db->call_function(); |
| 6 | ============================ |
| 7 | |
| 8 | This function enables you to call PHP database functions that are not |
| 9 | natively included in CodeIgniter, in a platform independent manner. For |
vlakoff | 3567246 | 2013-02-15 01:36:04 +0100 | [diff] [blame] | 10 | example, let's say you want to call the mysql_get_client_info() |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 11 | function, which is **not** natively supported by CodeIgniter. You could |
| 12 | do so like this:: |
| 13 | |
| 14 | $this->db->call_function('get_client_info'); |
| 15 | |
| 16 | You must supply the name of the function, **without** the mysql\_ |
| 17 | prefix, in the first parameter. The prefix is added automatically based |
| 18 | on which database driver is currently being used. This permits you to |
| 19 | run the same function on different database platforms. Obviously not all |
| 20 | function calls are identical between platforms, so there are limits to |
| 21 | how useful this function can be in terms of portability. |
| 22 | |
| 23 | Any parameters needed by the function you are calling will be added to |
| 24 | the second parameter. |
| 25 | |
| 26 | :: |
| 27 | |
| 28 | $this->db->call_function('some_function', $param1, $param2, etc..); |
| 29 | |
| 30 | Often, you will either need to supply a database connection ID or a |
| 31 | database result ID. The connection ID can be accessed using:: |
| 32 | |
| 33 | $this->db->conn_id; |
| 34 | |
| 35 | The result ID can be accessed from within your result object, like this:: |
| 36 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 37 | $query = $this->db->query("SOME QUERY"); |
| 38 | |
| 39 | $query->result_id; |