Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

having() Query in Codeigniter

by
Category:codeigniter
codeigniter mysql
having() Query in Codeigniter

This tutorial shows you how to write having query in codeigniter. This methods permits you to write the HAVING portion of your query. There are 2 possible syntaxes, 1 argument or 2.

Let’s create a having method in codeigniter

$this->db->having('user_id = 20');  // Produces: HAVING user_id = 20
$this->db->having('user_id',  20);  // Produces: HAVING user_id = 20

You can also pass an array of multiple values.

$this->db->having(array('title =' => 'My Title', 'id <' => $id));
// Produces: HAVING title = 'My Title', id < 45

If you are using a database that CodeIgniter escapes queries for, you can prevent escaping content by passing an optional third argument, and setting it to FALSE.

$this->db->having('user_id',  20);  
// Produces: HAVING `user_id` = 20 in some databases such as MySQL
$this->db->having('user_id',  20, FALSE);  
// Produces: HAVING user_id = 20

$this->db->or_having()

Identical to having(), only separates multiple clauses with “OR”.


0 Comments


Html code work in comment box


Related Post