×

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:29 AM
Modified: Nov 25, 2014 6:05 AM
Views: 26
Insert data into a database using bound values
  1. function functionName($varName)
  2. {
  3.         global $DB;
  4.         $query = "INSERT INTO tableName(columnName) VALUES(:varName)";
  5.         $statement = $DB -> prepare($query);
  6.         $statement -> bindValue(':varName',$varName);
  7.         $statement -> execute();
  8.         $status = $statement -> rowCount();
  9.         $statement -> closeCursor();
  10.  
  11.         return $status;
  12. }