• 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

mysql_result is defined but mysql_free_result warns it expected a resource

Doctrine 2 mapping referencing unique key

How to separate letters and digits from a string in php

Form Validation and Submission to database

Google Gmail API - How to login programatically?

dompdf and img tag, image wont show

CodeIgniter extend CI_URI undefined method

stay with the last 15 elements of an array [duplicate]

Laravel set default language not working

Split comma separated value from table column into rows using mysql?

Spam Filter in Contact Form

How to check user Permissions using Custom Middleware in Laravel

Handling expired token in Laravel

Undefined variable in Laravel 8 project (php 7.4)

Woocommerce redirect after add-to-cart error

About Contact Privacy policy Terms and conditions