×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Francesco St
Added: Jul 26, 2016 7:28 AM
Views: 6
database model draft select query
  1. try{    
  2.    
  3.    
  4. $pdo = new PDO("mysql:host=mysql.hostinger.it;dbname=u730190353_gerks", $usr, $pwd);
  5.     $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  6.    
  7.     $params = array();
  8.    
  9.     $stmt = $pdo->prepare($prepquery);
  10.      
  11. $prepquery = 'SELECT * FROM tab WHERE v = :v';
  12. $stmt->execute($params);
  13.  
  14. $result = $stmt->fetchAll();
  15.  
  16. # If one or more rows were returned...
  17. if ( count($result) ) {
  18.    // $strOut;
  19.     foreach($result as $row)
  20.         {
  21.    
  22.         }
  23.        
  24.      }
  25. }
  26. catch(PDOException $e)
  27.     {
  28.     echo 'ERROR: ' . $e->getMessage();
  29.     }