Archive for the ‘Mysql’ Category
Cheat Sheets
Who doesn’t like cheat sheet! Today i found an excellent repository of list of cheat sheets. Just go there http://www.addedbytes.com/cheat-sheets/
Why should we use PDO(PHP Data Object)?
PDO, The PHP Data Object extension is a data-access abstraction layer supports multiple databases(Mysql, SqlLite, PostGreSql). PDO is shipped with PHP 5.1
If you uses framework, you don’t have to do that, you use the database class,methods to handle this. If you are building application from scratch, you may build database class to interact with database with a list of methods. Thus PDO is perfact for you because
This extension has all the methods to get/set value with databases.
Excellent error trapping methods (following code is to connect with mysql database). See below -
<?php
$dsn = 'mysql:host=localhost;dbname=world;';
$user = 'user';
$password = 'secret';
try
{
$dbh = new PDO($dsn, $user, $password);
}
catch (PDOException $e)
{
echo 'Connection failed: ' . $e->getMessage();
}
?>
Mysql errors trapping methods.
Method to protect SQL injection attack.
Today’s popular E-Commerce tool Magento uses PDO. It’s excellent php extension so far.
Macbook Pro 15
Nikon D90