Here are some of the basic syntax for using PDO Objects.
The advantage of PDO objects is that you pass your variables into the SQL function using prepared statements.
Prepared statements are what are termed paramatised queries when working with program languages like Microsoft dot.net and
provide a way to prevents sql injection into databases.
SQL FETCH
<?php
$dbh = new [...]
Entries Tagged as 'PDO Objects'
Basic syntax of PDO Objects for PHP 5.1 and above
May 27th, 2012 · No Comments
Tags: General PHP · PDO Objects
Examples of using PDO objects in PHP
May 13th, 2012 · No Comments
<?php
//Example of fetching data from a database using PDO objects
# using the shortcut ->query() method here since there are no variable
# values in the select statement.
try {
$dbhost = “localhost”;
$dbname = “users”;
$dbusername = “root”;
$dbpass = “”;
//Connect to the database
$dbh = new PDO(“mysql:host=” . $dbhost . “;dbname=” . $dbname, $dbusername, $dbpass);
//the sql query
$sql = “SELECT * FROM [...]
Tags: General PHP · PDO Objects