Ejemplo n.º 1
0
 /**
  * Updates fields in a table for rows that match the provided criteria
  *
  * $newFields can be a complete row or it can be a sparsely populated
  * hashtable of values (where the keys are integers which are the column
  * indexes to update)
  *
  * @param string $tablename The table to update
  * @param array $newFields A hashtable (with integer keys) of fields to update
  * @param WhereClause $whereClause The criteria or NULL to update all rows
  */
 function updateSetWhere($tablename, $newFields, $whereClause)
 {
     $schema = $this->getSchema($tablename);
     $lockfp = $this->getLock($tablename);
     for ($i = 0; $i < count($this->tables[$tablename]); ++$i) {
         if ($whereClause === NULL || $whereClause->testRow($this->tables[$tablename][$i], $schema)) {
             foreach ($newFields as $k => $v) {
                 $this->tables[$tablename][$i][$k] = $v;
             }
         }
     }
     $this->writeTable($tablename);
     $this->releaseLock($lockfp);
     $this->loadTable($tablename);
 }