×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Thomas Seaford
Added: Nov 25, 2014 5:26 AM
Modified: Nov 25, 2014 6:03 AM
Views: 23
Select data from a table based on the bound values
  1. function [function name]()
  2. {
  3.     global $DB;
  4.     $query = "SELECT * FROM [table name] WHERE :valueName = $varName";
  5.     $statement = $DB -> prepare($query);
  6.     $statement -> bindValue(':valueName',$varName);
  7.     $statement -> execute();
  8.     $status = $statement -> rowCount();
  9.     $statement -> closeCursor();
  10.  
  11.     return $status;
  12.  
  13. #   $error = $statement -> errorCode();
  14. }