protected function checkTablesExist()
    {
        $table = $this->pdo_conn->quote($this->database_table);

        switch($this->database_driver) {
            case self::SI_DRIVER_SQLITE3:
                // query row count for sqlite, PRAGMA queries seem to return no
                // rowCount using PDO even if there are rows returned
                $query = "SELECT COUNT(id) FROM $table";
                break;

            case self::SI_DRIVER_MYSQL:
                $query = "SHOW TABLES LIKE $table";
                break;

            case self::SI_DRIVER_PGSQL:
                $query = "SELECT * FROM information_schema.columns WHERE table_name = $table;";
                break;
        }

        $result = $this->pdo_conn->query($query);

        if (!$result) {
            $err = $this->pdo_conn->errorInfo();

            if ($this->database_driver == self::SI_DRIVER_SQLITE3 &&
                $err[1] === 1 && strpos($err[2], 'no such table') !== false)
            {
                return false;
            }

            throw new Exception("Failed to check tables: {$err[0]} - {$err[1]}: {$err[2]}");
        } else if ($this->database_driver == self::SI_DRIVER_SQLITE3) {
            // successful here regardless of row count for sqlite
            return true;
        } else if ($result->rowCount() == 0) {
            return false;
        } else {
            return true;
        }
    }
protected function checkTablesExist()
    {
        $table = $this->pdo_conn->quote($this->database_table);

        switch($this->database_driver) {
            case self::SI_DRIVER_SQLITE3:
                // query row count for sqlite, PRAGMA queries seem to return no
                // rowCount using PDO even if there are rows returned
                $query = "SELECT COUNT(id) FROM $table";
                break;

            case self::SI_DRIVER_MYSQL:
                $query = "SHOW TABLES LIKE $table";
                break;

            case self::SI_DRIVER_PGSQL:
                $query = "SELECT * FROM information_schema.columns WHERE table_name = $table;";
                break;
        }

        $result = $this->pdo_conn->query($query);

        if (!$result) {
            $err = $this->pdo_conn->errorInfo();

            if ($this->database_driver == self::SI_DRIVER_SQLITE3 &&
                $err[1] === 1 && strpos($err[2], 'no such table') !== false)
            {
                return false;
            }

            throw new Exception("Failed to check tables: {$err[0]} - {$err[1]}: {$err[2]}");
        } else if ($this->database_driver == self::SI_DRIVER_SQLITE3) {
            // successful here regardless of row count for sqlite
            return true;
        } else if ($result->rowCount() == 0) {
            return false;
        } else {
            return true;
        }
    }
protected function checkTablesExist ( ) { $ table = $ this -> pdo_conn -> quote ( $ this -> database_table ) ; switch ( $ this -> database_driver ) { case self :: SI_DRIVER_SQLITE3 : // query row count for sqlite, PRAGMA queries seem to return no // rowCount using PDO even if there are rows returned $ query = "SELECT COUNT(id) FROM $table" ; break ; case self :: SI_DRIVER_MYSQL : $ query = "SHOW TABLES LIKE $table" ; break ; case self :: SI_DRIVER_PGSQL : $ query = "SELECT * FROM information_schema.columns WHERE table_name = $table;" ; break ; } $ result = $ this -> pdo_conn -> query ( $ query ) ; if ( ! $ result ) { $ err = $ this -> pdo_conn -> errorInfo ( ) ; if ( $ this -> database_driver == self :: SI_DRIVER_SQLITE3 && $ err [ 1 ] === 1 && strpos ( $ err [ 2 ] , 'no such table' ) !== false ) { return false ; } throw new Exception ( "Failed to check tables: {$err[0]} - {$err[1]}: {$err[2]}" ) ; } else if ( $ this -> database_driver == self :: SI_DRIVER_SQLITE3 ) { // successful here regardless of row count for sqlite return true ; } else if ( $ result -> rowCount ( ) == 0 ) { return false ; } else { return true ; } }
Checks if the necessary database tables for storing captcha codes exist

@throws Exception If the table check failed for some reason
@return boolean true if the database do exist, false if not
Checks if the necessary database tables for storing captcha codes exist