• 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

Insert multidimensional array to codeigniter cart

mysql slow on updates for a well optimized query

correct PHP headers for pdf file download

Laravel get user data with profile

Add and update products to session cart in Laravel

How to change product Image when variables are selected in Shop and Archive Pages?

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

Install mysql client in docker image

Two buttons one form

How do I enable error reporting in Laravel?

Symfony - EasyAdmin - Add and remove functions are ignored from AssociationField

Need to display only array value in JSON output

How to get total pages of PDF with FPDF?

Download & Save Zoom Recording in directory by PHP

Laravel Unknown Column 'updated_at'

About Contact Privacy policy Terms and conditions