• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

how to see if database exists with PDO [duplicate]

phpmysqlpdo


PHP Snippet 1:

$stmt = $pdo->query("SELECT COUNT(*) FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'DBName'");
return (bool) $stmt->fetchColumn();

PHP Snippet 2:

        try {
            $conn->exec($sql);
        } catch (PDOException $th) {
            echo "<br> sql error";
        }

Related Snippets

Backend cannot be reached after Typo3 login screen

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

Combining a describing and one array with data

Clients authentication and user authentication with laravel

Transpose csv file data [duplicate]

Adding the custom page with add_menu_page function on Wordpress

How do I enable error reporting in Laravel?

Combine multiple columns into an array as one of the key in a results set

Class AppHttpControllersUserController Does Not Exist

The sum of the user's points

Laravel Nova Dependency Container what are the allowed resource properties other than id in dependsOn

How to display MySQL table using php and edit it in a web browser

PhpSpreadSheet: How to save Workbook sheets in individual CSV files

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

PHP: set a (deep) array key from an array [closed]

About Contact Privacy policy Terms and conditions