• 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 display a view on laravel 8 and not have a 404 NOT FOUND page?

How to get multiple values with same key from an array PHP

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

Laravel lang slug in url

HTML + PHP + PHPMAILER

Query Optimization, changing the queries in the loop into a single processing query

Failing validation doesn't stop code execution in livewire component

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

dompdf and img tag, image wont show

Backend cannot be reached after Typo3 login screen

Multiply each value in array using array_map function

Undefined Array Key error when uploading image on php

How can I pass the list to the component variable in Laravel?

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

About Contact Privacy policy Terms and conditions