0
PHP: how to connect with database with PDO in object oriented php
How can i connect to my database with PDO method in OOP And how can i make class to make query later on in database?
4 Respuestas
+ 4
The try - catch statement and errmode_exceptions are optional but its good to have something to handle an error.
+ 5
try {
$db = new PDO("mysql:host=127.0.0.1;dbname=name", "root", "");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
die("Connection failed");
}
+ 1
Thanks toni
0
I figured that out :)
Thanks again