• 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

Undefined Array Key error when uploading image on php

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

Confirm Leave on External Links in Wordpress

How to create a cookie to store the timestamp of when a page is first loaded with php

Having trouble with PDO queries (Notice: Undefined index)

Upgrade PHP on AWS Linux

I can't delete my image when it is liked because of the foreign key in mysql

str_replace or preg_replace random number from string

Laravel 5 session not persisting after user is logged in

Laravel multi auth - Authentication user provider [] is not defined

php - add comma thousands separator but remove trailing zeros

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

How to add class name to an existing tag in php

I want a way to give path to my files which are outside of public folder in laravel

How to get values inside <![CDATA[values]] > using php DOM?

About Contact Privacy policy Terms and conditions