/** * @group ZF-3486 */ public function testTableRelationshipCanFindManyToManyRowsetViaConcreteInstantiation() { Table\Table::setDefaultAdapter($this->_db); $definition = $this->_getTableDefinition(); $bugsTable = new Table\Table('Bugs', $definition); $bugsRowset = $bugsTable->find(1); $bugRow = $bugsRowset->current(); $m2mRowset = $bugRow->findManyToManyRowset('Products', 'BugsProducts'); $this->assertEquals(3, $m2mRowset->count()); }
/** * Defined by Zend_Application_Resource_Resource * * @return \Zend\Db\Adapter\AbstractAdapter|null */ public function init() { if (null !== ($db = $this->getDbAdapter())) { if ($this->isDefaultTableAdapter()) { \Zend\Db\Table\Table::setDefaultAdapter($db); } return $db; } }
/** * @group ZF-10049 */ public function testSetDefaultMetadataCacheFromCacheManager() { $configCache = array('database' => array('frontend' => array('name' => 'Core', 'options' => array('lifetime' => 120, 'automatic_serialization' => true)), 'backend' => array('name' => 'Black Hole'))); $this->bootstrap->registerPluginResource('cachemanager', $configCache); $options = $this->_dbOptions; $options['defaultMetadataCache'] = 'database'; $resource = new MultidbResource($options); $resource->setBootstrap($this->bootstrap); $resource->init(); $this->assertType('Zend\\Cache\\Frontend\\Core', DBTable::getDefaultMetadataCache()); }
/** * @group ZF-5674 */ public function testTableAndIdentityWithVeryLongName() { Table\Table::setDefaultAdapter($this->_db); // create test table using no identifier quoting $this->_util->createTable('thisisaveryverylongtablename', array('thisisalongtablenameidentity' => 'IDENTITY', 'stuff' => 'VARCHAR(32)')); $tableName = $this->_util->getTableName('thisisaveryverylongtablename'); $table = new Table\Table('thisisaveryverylongtablename'); $row = $table->createRow($this->_getRowForTableAndIdentityWithVeryLongName()); $row->save(); $rowset = $table->find(1); $this->assertEquals(1, count($rowset)); $this->_util->dropTable('thisisaveryverylongtablename'); }
/** * Set the default db adapter * * @var \Zend\Db\Adapter\AbstractAdapter $adapter Adapter to set as default */ protected function _setDefault(Adapter\AbstractAdapter $adapter) { \Zend\Db\Table\Table::setDefaultAdapter($adapter); $this->_defaultDb = $adapter; }