• 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

Dropdown with current value from Mysql

Cant seem to get the Pagination to work on my WooCommerce REST API application?

PHP web3 ERC20 token function call

Dynamic dropdown Ajax PHP request

How Can I Do LIMIT 1, 2 In WP_Query

Input and output values for php into the browser?

Manage independently the decimal number of the price of each product [duplicate]

Laravel dosen't connect with Oracle

WordPress Security Standards want me to escape my html, but how to do it correctly?

How to change 'users' auth table and use another instead Laravel

Laravel Get Days In Month From Month Number?

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

hidden INPUT value not available in $_POST

Google API Heatmap Layer exception, why?

PHP Imap , php 7.4.3 on mac osx catalina

About Contact Privacy policy Terms and conditions