• 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

How to override header set in Apache config with more specific header in a virtual host

PHP password_verify

PHP echo values of all sub keys [duplicate]

Laravel Model save() & update() Not Saving

PHPExcel file download using AJAX call

Sum column values from multiple arrays

Find out the name of the last script that included the current one

Telegram bot doesn't answer

Wordpress add responsive srcset header image to theme

jQuery Ajax Post with data

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

Install mysql client in docker image

How can I stop a symfony process which is listening on http://127.0.0.1:8000

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

Passing a boolean value from checkbox in Laravel form

About Contact Privacy policy Terms and conditions