AutoExecute UPDATE with ADODB

Description PHP

An alternative way of updating a table using ADODB, utilising the AutoExecute function. Makes the code a bit tidier.

The Code Download

  1. <?php
  2. $record['lot_number']   = $_POST['lot_number'];
  3. $record['name']         = stripslashes($_POST['name']);
  4. $record['description']  = stripslashes($_POST['description']);
  5. $update_id = 'animal_id = ' . $_POST['animal_id'];
  6.  
  7. $result = $db->AutoExecute('table_name', $record, 'UPDATE', $update_id);
  8. if ($result === false) {
  9.     echo 'Error updating: '.$db->ErrorMsg();
  10. } else {
  11.     echo = 'Animal updated';
  12. }
  13. ?>

Credits

Added by JC on 15th November 2007

Comments

There are no comments about this snippet.

Post Comment Github Markdown Supported

You must be logged in to post a comment.

Login here to post a comment