|  | 
  stephen - 2005-05-07 18:02:47 /*** Lock A Table Item.
 *
 * @param   Table Name, A Lock Type
 * @access  public
 */
 function lock($table, $mode="write") {
 $this->connect();
 
 $query="lock tables ";
 if (is_array($table)) {
 while (list($key,$value)=each($table)) {
 if ($key=="read" && $key!=0) {
 $query.="$value read, ";
 } else {
 $query.="$value $mode, ";
 }
 }
 $query=substr($query,0,-2);
 } else {
 $query.="$table $mode";
 }
 $res = @mysql_query($query, $this->dblink);
 if (!$res) {
 $this->return_error("lock($table, $mode) failed.");
 return 0;
 }
 return $res;
 }
 
 /**
 * unlock A Table Item.
 *
 * @param   Table Name
 * @access  public
 */
 function unlock() {
 $this->connect();
 
 $res = @mysql_query("unlock tables");
 if (!$res) {
 $this->return_error("unlock() failed.");
 return 0;
 }
 return $res;
 }
 
 
 
 /**
 * Grabs A single field .
 *
 * @param      FieldName
 * @return     Values of the Filed
 * @access     public
 */
 function field($Name)
 {
 return $this->record[$Name];
 }
 
 
  Richard Munroe - 2005-05-09 20:07:27 - In reply to message 1 from stephenLooks reasonable on the surface of it.  I'll take a quick glance at the lock documentation on the MySQL site to make sure what you've done makes sense.  If so, I'll just include it.
 What do you want a field fetch.  I would have thought that once you've fetched the record, you would just grab the data from the returned array.  Or are you trying to avoid copying the data?  In which case what should probably be happening is returning a reference to the records rather than the records.
 
 Dick
 
  stephen - 2005-05-09 23:17:58 - In reply to message 2 from Richard MunroeIts just me being very very lazy 
  Richard Munroe - 2005-05-10 15:08:53 - In reply to message 3 from stephenYou might want to take a look at the SQLData class which, amoung other things, has a script called buildClass.php which builds a full object oriented interface to your tables, then you can use things like:
 $t->getField()
 
 to access things.  The SQLData and the dm.DB classes interact to give you powerful and simple access to your tables.  A little more mechanism, but you get something for it, for example, after you've made all changes to your data using the class you created you can simply:
 
 $t->update()
 
 and the class figures out what's changed, what the key fields to use are, and does the update for you.
 
 I've even published a paper on how this stuff got created.  It's NOT a programming manual but it justifies the use pretty well.  Check out:
 
 http://www.csworks.com/publications/APG.pdf
 
 Dick
 
  Richard Munroe - 2005-10-13 18:27:55 - In reply to message 4 from Richard MunroeI finally got around to updating with the lock/unlock functions you provided.  As per our earlier discussion I WON'T add the fetch function as I think that is better provided by a table level abstraction provided by SQLData.  Thanks again for the suggestion and the code and my apologies for taking so long to add the functionality.
 Dick Munroe
 
 |