Beispiel #1
0
 /**
  * @return $successfulDelete
  */
 public function delete() : bool
 {
     if (static::DELETE) {
         $sucess = (bool) $this->rowGateway->delete();
     } else {
         $success = false;
     }
     return $success;
 }
Beispiel #2
0
 /**
  * Constructor
  *
  * @param string                              $primaryKeyColumn
  * @param string|AbstractTableGateway|\Zend\Db\Sql\TableIdentifier $table
  * @param Adapter|Sql                         $adapterOrSql
  *
  * @return \Pi\Db\RowGateway\RowGateway
  */
 public function __construct($primaryKeyColumn, $table, $adapterOrSql = null)
 {
     // setup primary key
     $this->primaryKeyColumn = $primaryKeyColumn ?: $this->primaryKeyColumn;
     $this->pkColumn = $this->primaryKeyColumn;
     if ($table instanceof AbstractTableGateway) {
         $this->setModel($table);
         $table = $table->getTable();
     }
     parent::__construct($this->primaryKeyColumn, $table, $adapterOrSql);
 }
 /**
  * Offset unset
  *
  * @param  string $offset
  * @return AclAwareRowGateway
  */
 public function offsetUnset($offset)
 {
     //if(!$this->acl->hasTablePrivilege($this->table, 'bigedit')) {
     // Enforce field write blacklist
     $this->acl->enforceBlacklist($this->table, $offset, Acl::FIELD_WRITE_BLACKLIST);
     //}
     return parent::offsetUnset($offset);
 }
Beispiel #4
0
 public function delete()
 {
     parent::delete();
 }
 /**
  * @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());
 }
Beispiel #6
0
 /**
  * Constructor
  *
  * @param \Zend\Db\Adapter\Adapter $adapter Database adapter
  */
 public function __construct($adapter)
 {
     parent::__construct('id', 'session', $adapter);
 }
Beispiel #7
0
 /**
  * Constructor
  *
  * @param \Zend\Db\Adapter\Adapter $adapter Database adapter
  */
 public function __construct($adapter)
 {
     parent::__construct('id', 'resource_tags', $adapter);
 }
Beispiel #8
0
 /**
  * Constructor
  *
  * @param \Zend\Db\Adapter\Adapter $adapter Database adapter
  */
 public function __construct($adapter)
 {
     parent::__construct(array('core', 'id'), 'change_tracker', $adapter);
 }
Beispiel #9
0
 public function testSave()
 {
     // If we insert a new row, we should be able to read the ID after saving it.
     // For the purposes of this test, the mocks are set up to always generate an
     // id of "example" (see setup method above).
     $row = new RowGateway('id', 'fake', $this->mockAdapter);
     $row->foo = 'bar';
     $row->save();
     $this->assertEquals('example', $row->id);
     $this->assertEquals('example', $row['id']);
 }
Beispiel #10
0
 /**
  * Set attribute value
  *
  * @param RowGateway $entityRow entity object
  * @param RowGateway $attribute attribute object
  * @param mixed $value attribute value
  */
 public function setAttributeValue($entityRow, $attribute, $value)
 {
     if (is_string($attribute)) {
         $attribute = $this->getAttribute($attribute);
     }
     $typeTable = $this->getTypeTable($attribute);
     $valueRow = $this->getValueRow($entityRow, $attribute);
     if (!$valueRow) {
         $valueRow = new RowGateway('id', $typeTable->getTable(), $typeTable->getAdapter());
         $valueRow->attribute_id = $this->getAttributeId($attribute);
         $valueRow->entity_id = $this->getEntityId($entityRow);
     }
     $valueRow->value = $value;
     $valueRow->save();
 }
Beispiel #11
0
 /**
  * Constructor
  *
  * @param \Zend\Db\Adapter\Adapter $adapter Database adapter
  */
 public function __construct($adapter)
 {
     parent::__construct('id', 'oai_resumption', $adapter);
 }
Beispiel #12
0
 /**
  * Constructor
  *
  * @param \Zend\Db\Adapter\Adapter $adapter Database adapter
  */
 public function __construct($adapter)
 {
     parent::__construct('id', 'user_resource', $adapter);
 }
Beispiel #13
0
 /**
  * Constructor
  *
  * @param \Zend\Db\Adapter\Adapter $adapter Database adapter
  */
 public function __construct($adapter)
 {
     parent::__construct('id', 'comments', $adapter);
 }
 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();
 }
Beispiel #15
0
 /**
  * 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);
 }