• 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

PHP drop down list using array's and foreach (else and for) code

Laravel Model save() & update() Not Saving

Yii2: How do I debug console commands?

Store multiple fields in JSON column (Nova CMS)

Show Custom Data in Woocommerce Order Details Admin Area

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

PHP mail function is sending blank message body

How to use PHPCBF to fix one issue at a time?

MySQL/PHP - Web Based Game -User specific inventory table or 1 giant table? Another option?

ConstraintViolationListInterface to Exception in Symfony

PHP: convert all UTF-8 characters to HTML entities

passwordless LDAP login and get user information using Kerberos ticket in PHP

PHP Form Not Inserting

How to extract price from given url using Xpath?

how to hide previous markers when new markers added in google map javascript api

About Contact Privacy policy Terms and conditions