-
Notifications
You must be signed in to change notification settings - Fork 3
Home
GrumpyCrouton edited this page Oct 19, 2022
·
10 revisions
GrumpyPDO is an extension of PDO, so any regular PDO methods also work with GrumpyPDO. This means you can switch from regular PDO to GrumpyPDO at any time and it won't break your existing code.
- GrumpyPDO has Composer support! The composer package is
grumpycrouton/grumpypdo
- Copy
grumpypdo.php
into your server, then include it in your page and initialize it as a variable.
include "grumpypdo.php";
$db = new GrumpyPDO("localhost", "username", "password", "database");
protected $default_attributes = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
);
If you want to add more attributes, or alter existing ones, pass an array of attributes as a key->value pair as the 5th parameter of the class initialization.
Whatever you pass will be added to, or overwrite, the existing attributes.
__construct($hostname, $username, $password, $database, $attributes = array(), $dsn_prefix = "mysql", $dsn_param_string = "")