• 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

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

How to check user Permissions using Custom Middleware in Laravel

Laravel Collections. Is there some kind of assertStructure method?

php 7 php.ini upload_max_filesize not working

find in set in laravel ? example

json_encode turns array into an object

Having issue with matching rows in the database using PDO

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

laravel sanctum Route [login] not defined

Where do I need to place a hook for phpunit?

How to submit a form when page loads using JavaScript?

LARAVEL: How to fetch id dynamically in a query builder?

Reading input in php from terminal

PHPSpreadsheet - How Do I Use Auto Migration Tool

Update Order custom Field value with WooCommerce REST API

About Contact Privacy policy Terms and conditions