Update:Archive/1.0/Developers: Difference between revisions

Line 134: Line 134:
  }
  }


Here, $dbh is a static handle so if it has already been instantiated, it can be reused throughout the entire execution of the script -- likewise with $result. db_connect() is another wrapper that connects to the database and db_error() is a wrapper to handle database errors gracefully (and silently) - we will not go into that right now, assume it works for the example. This ultimately lets us to reduce the code:
Here, $dbh is a static handle so if it has already been instantiated, it can be reused for concurrent calls of the query function -- likewise with $result. db_connect() is another wrapper that connects to the database and db_error() is a wrapper to handle database errors gracefully (and silently) - we will not go into that right now, assume it works for the example. This ultimately lets us to reduce the code:


  $sql_result = db_query("SELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id");
  $sql_result = db_query("SELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id");
3,035

edits