It's All About Me

make them benefit

Archive for the ‘Mysql’ Category

Cheat Sheets

without comments

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/

Thanks Dave Child. I’m sure, you guys like it too.

Written by kodegeek

August 21, 2009 at 11:15 am

Why should we use PDO(PHP Data Object)?

without comments

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.

Written by kodegeek

June 24, 2009 at 7:40 pm

Posted in Mysql, Php