/** * onBeforeDelete * * @param mixed $pk * * @return void */ public function onBeforeDelete($pk) { if ($this->table instanceof Table) { $this->tableClone = clone $this->table; $this->tableClone->load($pk); } }
public function testGlobalRelationConfig() { /** @var RelationContainer $relations */ $relations = Container::getInstance()->get('relation.container'); $relation = $relations->getRelation(static::TABLE_LOCATIONS); $relation->addOneToMany('sakuras', new StubTableSakura(), array('id' => 'location')); $relation->addOneToMany('roses', new StubTableRose(), array('id' => 'location')); $location = new Table(static::TABLE_LOCATIONS, 'id', \JFactory::getDbo()); $location->load(3); $sakuras = $location->sakuras; $roses = $location->roses; $this->assertInstanceOf('Windwalker\\Data\\Data', $sakuras[0]); $this->assertInstanceOf('Windwalker\\Data\\DataSet', $sakuras); $this->assertInstanceOf('Windwalker\\Data\\DataSet', $roses); $this->assertEquals(array(11, 12, 13, 14, 15), $sakuras->id); $this->assertEquals(array(11, 12, 13, 14, 15), $roses->id); $relations->setRelation(static::TABLE_LOCATIONS, new Relation()); }
/** * Method to load a row from the database by primary key and bind the fields * to the JTable instance properties. * * @param mixed $keys An optional primary key value to load the row by, or an array of fields to match. If not * set the instance property value is used. * @param boolean $reset True to reset the default values before loading the new row. * * @return boolean True if successful. False if row not found. * * @throws InvalidArgumentException * @throws RuntimeException * @throws UnexpectedValueException */ public function load($keys = null, $reset = true) { return parent::load($keys, $reset); }