• 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 search for a file with php

MySQL - Connection failed: No route to host

Laravel Nova, route not found

The sum of the user's points

Populate Dynamic Dropdowns List in Codeigniter

java URL working on browser but not in client program

How to validate Envato Purchase Code in PHP

possible options to create pdf file using html elements to generate invoice in php and codeigniter

How to make autocomplete work in foreach php loop? (vscode, intellisense)

Call to undefined function openssl_decrypt

How can I get user id from session in javascript?

Is there an equivalent of DynamoDB on Azure as a PHP session Handler

Adding Multiple Custom Post Types in Wordpress

Use same method for inertia response and json response Laravel Jetstream

How to unlink image from folder?

About Contact Privacy policy Terms and conditions