
Jul 10, 2013
Posted by
Unknown
2
comments
|
11:52 PM

Inserting data into database is the most common operation. Using PDO this is just two step process. in this article lets see how to inset data using PDO
Bellow is very simple insert code.. lets look at it..
//STH means Statement Handler
$STH = $DBH->prepare("INSERT INTO my_table VALUES('my php pages')");
$STH->execute();
This operation can be done using exec() function also. but it is good to use prepare method because it...
Jul 9, 2013
Posted by
Unknown
No comments
|
5:16 AM

PDO can use exceptions and handle errors. Every time when you use PDO it is good to use it with in try catch block. there is three error modes available in PDO and you can set the error mode attribute on your database.
Lets look at the code.
$DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT );
$DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );...
Jul 5, 2013
Posted by
Unknown
7
comments
|
7:37 AM

Most of the PHP developers using Mysql or Mysqli php functions when they work with databases. but PHP has introduced new extension call PDO in PHP 5.1. this methord is way better and very productive. PDO is stands for PHP Data Objects.
Note : Mysql functions is removed from PHP 5.5. so its better to use PDO or Mysqi. I strongly recommend to use PDO.
PDO Supported Databases Drivers List
You can use bellow code to find which driver is...
Jul 2, 2013
Posted by
Unknown
1 comment
|
9:34 AM
You can easily update and delete data in mysql tables using php. This update & delete functionality is almost same as insert data. just sql query is difference.
Lets look at how to update data. for this you have to use UPDATE sql statement. lets look at the code below.
//make connection
$con = mysql_connect("localhost","root","123");
//check connection
if(!$con)
{
die('Could not connect to the database:'.mysql_error());
}
//select database
$db=mysql_select_db("my_database",$con);
...
Jul 1, 2013
Posted by
Unknown
No comments
|
10:13 AM
Today we gonna talk about how to retrieve data from a mysql database. in last three lessons we learned about how to create a connection to database, how to create database & tables and how to insert data. if you have any problem with those things you better read few last post before go through this. ok lets begin.
In this case we have to use Sql SELECT statement through mysql_query() function to fetch the data from mysql tables. There is several...
Subscribe to:
Posts
(
Atom
)