Latest Tutorial

PDO also supports bound statements where you can explicitly bind an immediate value or a variable to a named or positional placeholder. Look this sample:
<?php

// configuration

$dbhost        = "localhost";

$dbname        = "pdo";

$dbuser        = "root";

$dbpass        = "";

// database connection

$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);

// new data

// query

$sql = "SELECT * FROM books";

$q = $conn->prepare($sql);

$q->execute();

$q->bindColumn(1, $id);

$q->bindColumn(2, $title);

$q->bindColumn(3, $author);

while($q->fetch())

{

echo "$title, $author <br/>";

}

?>

0 comments:

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Top
Blogger Template