What's the equivalent of this PDO method in CI3 |
You can achieve the same result in CodeIgniter 3 Query Builder with Mysqli driver using the following code:
$this->db->select('set_name, set_value'); $this->db->from('tbl_settings'); $this->db->like('set_name', 'sys_'); $query = $this->db->get(); $results = $query->result(); $sys_version = null; foreach ($results as $result) { if ($result->set_name == 'sys_version') { $sys_version = $result->set_value; break; } } This code will retrieve all records from the tbl_settings table where set_name contains the string 'sys_' and return an array of objects containing the set_name and set_value columns. Then, it loops through the results to find the value for the 'sys_version' key and assigns it to the $sys_version variable. Note that unlike the PDO method, this method requires you to loop through the results to find the desired value, as there is no built-in method to fetch key-value pairs in CodeIgniter 3 Query Builder with Mysqli driver. |
Messages In This Thread |
What's the equivalent of this PDO method in CI3 - by demon_da - 01-05-2023, 02:37 AM
RE: What's the equivalent of this PDO method in CI3 - by kenjis - 01-06-2023, 06:40 PM
RE: What's the equivalent of this PDO method in CI3 - by demon_da - 01-07-2023, 01:41 PM
RE: What's the equivalent of this PDO method in CI3 - by kenjis - 01-07-2023, 05:20 PM
RE: What's the equivalent of this PDO method in CI3 - by MitchelBraybh - 03-30-2023, 03:24 AM
RE: What's the equivalent of this PDO method in CI3 - by GerishSonya - 04-19-2023, 11:04 PM
|