• 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 Array split string and Integers

Getting output of MS stored procedure on php call

Mysqli multi query error

merge all files in directory to one text file

PHP - CURL using HTTPS [closed]

PHP - installing Xdebug on Mac with XAMPP (Unix File)

Symfony 4: "Autowire: you should configure its value explicitly."

How to get multiple values with same key from an array PHP

Creating live search with AJAX and CodeIgniter

enable Apache http Authorization header

Object of class stdClass could not be converted to string error

PHP: Calling MySQL Stored Procedure with Both INPUT AND OUTPUT Parameters (NOT "INOUT")

Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

Laravel lang slug in url

How to fix 'Data has already been sent to output, unable to output PDF file' in MPDF

About Contact Privacy policy Terms and conditions