예제 #1
0
파일: IOTest.php 프로젝트: Zunair/xataface
 function test_setByID()
 {
     $this->assertEquals('John', Dataface_IO::getByID('Profiles?id=10#fname'));
     Dataface_IO::setByID('Profiles?id=10#fname', 'Jimmy');
     $this->assertEquals('Jimmy', Dataface_IO::getByID('Profiles?id=10#fname'));
     $this->assertEquals('Teacher', Dataface_IO::getById('Profiles/appointments?id=10&appointments::id=2#position'));
     Dataface_IO::setByID('Profiles/appointments?id=10&appointments::id=2#position', 'firefighter');
     $this->assertEquals('firefighter', Dataface_IO::getById('Profiles/appointments?id=10&appointments::id=2#position'));
     Dataface_IO::setByID('Profiles?id=10', array('fname' => 'Bobby', 'lname' => 'Brown'));
     $r =& Dataface_IO::getByID('Profiles?id=10');
     $this->assertEquals(array('fname' => 'Bobby', 'lname' => 'Brown'), $r->vals(array('fname', 'lname')));
 }
예제 #2
0
 /**
  * @see Dataface_IO::getByID()
  */
 function &df_get($uri, $filter = null)
 {
     $res = Dataface_IO::getByID($uri, $filter);
     return $res;
 }
예제 #3
0
파일: IO.php 프로젝트: promoso/HVAC
 /**
  * Sets a value by ID.
  */
 static function setByID($uri, $value)
 {
     @(list($uri, $fieldname) = explode('#', $uri));
     $record =& Dataface_IO::getByID($uri);
     if (PEAR::isError($record)) {
         return $record;
     }
     if (!is_object($record)) {
         return PEAR::raiseError("Could not find record matching '{$uri}'.");
     }
     if (isset($fieldname)) {
         $res = $record->setValue($fieldname, $value);
     } else {
         $res = $record->setValues($value);
     }
     if (PEAR::isError($res)) {
         return $res;
     }
     $res = $record->save();
     return $res;
 }