So I recently decided to switch to PDO due to the mysqli prepared statement complexity and irregularities. This was my mysqli function to test for a database:
public static function is_database($database) {
self::connect();
if( mysqli_select_db(self::$conn,$database) ) {
self::$dbname = $database;
return true;
} else {
return false;
}
self::disconnect();
}
The only thing I've read so far about PDO and a database of anything was this:
$pdo->exec("use database");
Which is not what I want, unless using this with a try catch would work. Something of this sort
public static function is_database($database){
self::connect();
try {
self::$conn->exec('use '.$database);
return true;
} catch(PDOException $e){
print($e->getMessage();
return false;
die();
}
}
Need a little assistance for the 1 hour new PDO user. Thanks for any advice.