PHP Classes

File: SQL File

Recommend this page to a friend!
  Classes of Kabir Hossain   PHP CodeIgniter Tips Tricks   MySQL_tips_tricks.sql   Download  
File: MySQL_tips_tricks.sql
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP CodeIgniter Tips Tricks
Collection of tips and examples to use CodeIgniter
Author: By
Last change:
Date: 1 month ago
Size: 1,868 bytes
 

Contents

Class file image Download
//Mysql using process $con = mysql_connect("DBhost", "DBuser", "DBpass"); mysql_select_db("database",$con); $result = mysql_query("SELECT * FROM employee"); $res = mysql_fetch_assoc($result); //Mysqli using process $mysqli = new mysqli("DBhost", "DBuser", "DBpass", "database"); $result = $mysqli->query("SELECT * FROM employee"); $res = $result->fetch_assoc(); SELECT UNIX_TIMESTAMP(field_name) AS fiel_name_utstmp FROM your_table SELECT NOW(),CURDATE(),CURTIME() SELECT * FROM Persons WHERE LastName IN ('Hansen','Pettersen') /* create a table with field default data is date */ CREATE TABLE Orders ( OrderId int NOT NULL, ProductName varchar(50) NOT NULL, OrderDate datetime NOT NULL DEFAULT NOW(), PRIMARY KEY (OrderId) ) /* after that, you can add new record without worry about date */ INSERT INTO Orders (ProductName) VALUES ('Jarlsberg Cheese') -- compare 2 datetime DATE_FORMAT(`date`, '%Y%m%d') >= DATE_FORMAT(NOW(), '%Y%m%d') SELECT * FROM fiberbox WHERE field LIKE '%1740 %' OR field LIKE '%1938 %' OR field LIKE '%1940 %'; SELECT * from fiberbox where field REGEXP '1740|1938|1940'; // COMPARE DATE IN MYSQL mysql> select datediff('2011-06-18','2011-06-25'); +-------------------------------------+ | datediff('2011-06-18','2011-06-25') | +-------------------------------------+ | -7 | +-------------------------------------+ //add date to compare date field in MySQL expiry_date <= DATE_ADD(CURDATE(), INTERVAL -1 DAY) expiry_date = DATE_ADD(CURDATE(), INTERVAL " . $param_renewal_trigger_days->value . " DAY) ALTER TABLE contacts ADD email VARCHAR(60) AFTER name; -- FIRST ALTER TABLE `pa_policy` CHANGE `prev_policy_number` `prev_policy_id` INT(11) DEFAULT NULL -- http://bradmontgomery.blogspot.com/2009/04/how-to-set-up-foreign-key-constraint-in.html