• 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 fix 'Data has already been sent to output, unable to output PDF file' in MPDF

Display the default discounted price and percentage on Woocommerce products

Having issue with matching rows in the database using PDO

Installing Composer - Internal Error

Querying only one row from a one to many relationship laravel

Unable to match results of php hash_hmac() and coldfusion hmac()

Hide email address with stars (*)

How to validate Envato Purchase Code in PHP

xdebug 3 not working in ubuntu 20.04 with docker

How to get the ID of the link in another page in php

Having issue with matching rows in the database using PDO

Adding custom body class to the custom archive pages

Artisan, creating tables in database

If you intend you use SMTP, add your SMTP Code after this Line

Laravel Sanctum CSRF not authenticating

About Contact Privacy policy Terms and conditions