I am running a site that is using a design pattern (can’t remember what its called but its the one where you have a registry file that is on all pages and can store objects). Anyway, I need to create an object for database operations and would like to use PDO.
So i need to create a class that extends the pdo class.
Can someone either point me in the direction of a tutorial, a class someone has already made or outline the structure so i can make my own? I can’t currently find a completed one online or a tutorial to make one.
It’ll show you how to make a PDO connection:
$conn = new PDO(‘mysql=localhost;dbname=db’, $username, $password);
And how to make prepared/bound queries, to prevent SQL injections:
$query = “select count(*) from table where email = ?”;
$stmt = $conn->prepare($query);
$stmt->bindParam(1, $variable, PDO::PARAM_STR);
$result = $stmt->fetchAll();
Hope that helps a wee bit.
Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Back End’ is closed to new topics and replies.