• 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

Laravel database insert with combining array and string

How to render html from a @foreach loop in a textarea

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

codeigniter 4 running error first time with xampp

Pages are working fine on localhost but not running on the hosting server

How to run or debug php on Visual Studio Code (VSCode)

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

Not able to access model in the controller mautic

Make survey at laravel 5.4 and MySQL

WHM Enabling mod_rewrite

How to trim a video by 4 fragments to 4 seconds using the PHP-FFMpeg?

how can I set a session variable in Drupal 8 and get it in a php script?

Open a popup box after receiving result from ajax

Wordpress how to get the post thumbnail inside a figure tag

Add and update products to session cart in Laravel

About Contact Privacy policy Terms and conditions