• 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

renameColumn migration fails for existing column with columns does not exist error

Get image type from base64 encoded src string

Laravel SQL query midnight time not showing

How do I refresh a DIV content?

Wordpress 'post_type_link' hides permalink

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

Error loading MySQLdb Module 'Did you install mysqlclient or MySQL-python?'

printing all running session variable in laravel 5.1

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

Dynamic table in HTML using MySQL and php

Add 2 Webcam in one page with WebcamJS

Detect if PHP session exists

Fatal error: [] operator not supported for strings

How to fix " Uncaught TypeError: Argument 1 passed to JpGraphException::defaultHandler() " problem in php 7.1.3 and jpgraph 4.2.6?

Telegram bot doesn't answer

About Contact Privacy policy Terms and conditions