Beispiel #1
0
 public function load($id)
 {
     if (empty($id)) {
         throw new InvalidArgumentException('load() method requires an id');
     }
     $resultSet = $this->adapter->query('SELECT * FROM `forum_posts` WHERE `id` = ?', array($id));
     $rowData = $resultSet->current();
     if (!$rowData) {
         throw new Exception('No post ' . $id . ' found');
     }
     return clone parent::populate($rowData->getArrayCopy(), true);
 }
 /**
  * Populate Data
  *
  * @param  array $rowData
  * @param  bool  $rowExistsInDatabase
  * @return AclAwareRowGateway
  */
 public function populate(array $rowData, $rowExistsInDatabase = false)
 {
     // IDEAL OR SOMETHING LIKE IT
     // grab record
     // populate skip acl
     // diff btwn real record $rowData parameter
     // only run blacklist on the diff from real data and the db data
     $rowData = $this->preSaveDataHook($rowData, $rowExistsInDatabase);
     //if(!$this->acl->hasTablePrivilege($this->table, 'bigedit')) {
     // Enforce field write blacklist
     // $attemptOffsets = array_keys($rowData);
     // $this->acl->enforceBlacklist($this->table, $attemptOffsets, Acl::FIELD_WRITE_BLACKLIST);
     //}
     return parent::populate($rowData, $rowExistsInDatabase);
 }
 /**
  * @covers Zend\Db\RowGateway\RowGateway::toArray
  */
 public function testToArray()
 {
     $this->rowGateway->populate(array('id' => 5, 'name' => 'foo'), true);
     $this->assertEquals(array('id' => 5, 'name' => 'foo'), $this->rowGateway->toArray());
 }
 public function demoRowGatewayStandaloneAction()
 {
     // query the database
     $resultSet = $this->localAdapter->query('SELECT * FROM test WHERE id = ?', array(2));
     // get array of data
     $rowData = $resultSet->current()->getArrayCopy();
     // row gateway
     $rowGateway = new RowGateway('id', 'test', $this->localAdapter);
     $rowGateway->populate($rowData, true);
     $rowGateway->title = 'New title - RowGateway';
     $rowGateway->save();
     // or delete this row:
     // $rowGateway->delete();
 }