File: index.php

Recommend this page to a friend!
  Classes of adam berger  >  PHP Singleton Database Class PDO  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Singleton Database Class PDO
Connect to many types of database using PDO
Author: By
Last change:
Date: 1 month ago
Size: 1,509 bytes
 

 

Contents

Class file image Download
<?php
       
require 'SingletonDB.php';

         try {
           
          
// $singletonDB = SingletonDB::getInstance()->connectMysql();
       // $singletonDB = SingletonDB::getInstance()->connectMicrosoftSqlServer();
           // $singletonDB = SingletonDB::getInstance()->connectPostgreSql();
        
          
$singletonDB = SingletonDB::getInstance()->connectSQLite();
         
$query = "SELECT `nameUser` FROM `testwielki`";
        
// $result = $singletonDB->prepare($query);
         
$result = $singletonDB->query($query);
         
$result->execute();
         
$as = $result->fetchAll();
                 
print_r($as);
             echo
count($result->fetchAll());
            
       if(
$result->rowCount() > 0){
         
$as = $result->fetchAll();
               
print_r($as);
        
$result->closeCursor();
           }
         } catch (
Exception $ex) {
             
$mesage1 = " ";
         echo
$mesage1 .= $ex->getTraceAsString()
                .
$ex->getMessage().'<br />'
               
.$ex->getCode().'<br />'
               
.$ex->getFile().'<br />'
               
.$ex->getLine().'<br />'
               
.$ex->getPrevious();
         } catch(
PDOException $ep){
                 
$mesage1 = " ";
             echo
$mesage1 .= $ep->getTraceAsString()
                .
$ep->getMessage().'<br />'
               
.$ep->getCode().'<br />'
               
.$ep->getFile().'<br />'
               
.$ep->getLine().'<br />'
               
.$ep->getPrevious();
             }


For more information send a message to info at phpclasses dot org.