Category: mysql

Grouping Query in Codeigniter

Query grouping allows you to create groups of WHERE clauses by enclosing them in parentheses. This will allow you to create queries with complex WHERE clauses. Nested groups are supported. $this->db->group_start() Starts a new group by adding an opening parenthesis to the WHERE clause of the query. $this->db->or_group_start() Starts a new group by adding an […]

Prepared Statements in PDO – MySQL

A prepared statement (also known as parameterized statement) is simply a SQL query template containing placeholder instead of the actual parameter values. Here is example of PDO statements. <?php $servername = “localhost”; $username = “root”; $password = “”; $dbname = “myDBPDO”; try {     $conn = new PDO(“mysql:host=$servername;dbname=$dbname”, $username, $password);     // set the PDO error mode to exception     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);     // […]