• 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

Prestashop webservice API creating cart rules

PHP web3 ERC20 token function call

Eloquent insert id with sequence next value

Check if string contains a value in array [duplicate]

500 (Internal Server Error) with Laravel & Docker [duplicate]

PHP-Sort array based on another array?

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

Laravel post contact form giving me error 419

How to get variable from JavaScript to PHP [duplicate]

Woocommerce redirect after add-to-cart error

401 Unauthorized only occurring on some pages in Laravel 8

Getting public posts of a random user from Facebook API

(Cache::lock()) -> get() -- Under what conditions does it return false?

Correct way to use LIKE '%{$var}%' with prepared statements?

Creating command to backup MySql database in Laravel

About Contact Privacy policy Terms and conditions