本文整理汇总了PHP中Doctrine_Collection::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Collection::getTable方法的具体用法?PHP Doctrine_Collection::getTable怎么用?PHP Doctrine_Collection::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Collection
的用法示例。
在下文中一共展示了Doctrine_Collection::getTable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _saveInCache
/**
* Save in cache
*
* @return void
*/
private function _saveInCache(Zend_Cache_Core $cache)
{
$cacheData = array();
$cacheData['tableName'] = $this->_dbData->getTable()->getComponentName();
$cacheData['dataArray'] = $this->_dbData->toArray(self::SERIALIZATION_DEEP);
$cache->save($cacheData, $this->_cacheKey);
}
示例2: testInsertMultiple
public function testInsertMultiple()
{
$count = count($this->dbh);
$listener = new Transaction_TestLogger();
$users = new Doctrine_Collection('User');
$users->getTable()->getConnection()->setListener($listener);
$this->connection->beginTransaction();
$users[0]->name = 'Arnold';
$users[1]->name = 'Vincent';
$users[0]->save();
$users[1]->save();
$this->assertEqual($listener->pop(), 'onSave');
$this->assertEqual($listener->pop(), 'onInsert');
$this->assertEqual($listener->pop(), 'onPreInsert');
$this->assertEqual($listener->pop(), 'onPreSave');
$this->assertEqual($listener->pop(), 'onSave');
$this->assertEqual($listener->pop(), 'onInsert');
$this->assertEqual($listener->pop(), 'onPreInsert');
$this->assertEqual($listener->pop(), 'onPreSave');
$this->assertEqual($users[0]->id, 2);
$this->assertEqual($users[1]->id, 3);
$this->assertTrue($count < count($this->dbh));
$this->connection->commit();
$this->assertEqual($listener->pop(), 'onTransactionCommit');
$this->assertEqual($listener->pop(), 'onPreTransactionCommit');
}
示例3: getObjects
public function getObjects()
{
$objects = parent::getObjects();
if ($objects instanceof Doctrine_Record) {
$objects = new Doctrine_Collection($objects->getTable());
}
return $objects;
}
示例4: _buildObjects
/**
* Remaps a doctrine collection so that the keys of the colleciton "array"
* are the ids of the underlying objects. This makes the collection
* easier to deal with then replacing objects
*
* @return Doctrine_Collection
*/
protected static function _buildObjects(Doctrine_Collection $collection)
{
$objects = new Doctrine_Collection($collection->getTable());
foreach ($collection as $key => $value) {
$objects[$value->slug] = $value;
}
return $objects;
}
示例5: _setTable
/**
* @param Doctrine_Record|Doctrine_Collection|Array $data
* @param null|Doctrine_Table $table
* @return Kebab_Validate_Doctrine_Table
*/
protected function _setTable($data, $table = null)
{
if (is_null($table) && $data instanceof Doctrine_Record) {
$this->_table = $data->getTable();
}
if (!is_null($table) && $table instanceof Doctrine_Table) {
$this->_table = $table;
}
if (is_string($table) && !$table instanceof Doctrine_Table) {
$this->_table = Doctrine_Core::getTable($table);
}
return $this;
}
示例6: merge
/**
* Merges collection into $this and returns merged collection
*
* @param Doctrine_Collection $coll
* @return Doctrine_Collection
*/
public function merge(Doctrine_Collection $coll)
{
$localBase = $this->getTable()->getComponentName();
$otherBase = $coll->getTable()->getComponentName();
if ($otherBase != $localBase && !is_subclass_of($otherBase, $localBase)) {
throw new Doctrine_Collection_Exception("Can't merge collections with incompatible record types");
}
foreach ($coll->getData() as $record) {
$this->add($record);
}
return $this;
}
示例7: getCollectionAsXml
/**
* Return an collection of records as XML.
*
* @see getRecordAsXml for options to set in the record class to control this.
*
* @param Doctrine_Collection $collection
* @param SimpleXMLElement $xml
* @return string Xml as string
*/
public static function getCollectionAsXml(Doctrine_Collection $collection, SimpleXMLElement $incomming_xml = null)
{
$collectionName = Doctrine_Lib::plurelize($collection->getTable()->tableName);
if ($collection->count != 0) {
$record = $collection[0];
$xml_options = $record->option("xml");
if (isset($xml_options["collection_name"])) {
$collectionName = $xml_options["collection_name"];
}
}
if (!isset($incomming_xml)) {
$new_xml_string = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><" . $collectionName . "></" . $collectionName . ">";
$xml = new SimpleXMLElement($new_xml_string);
} else {
$xml = $incomming_xml->addChild($collectionName);
}
foreach ($collection as $key => $record) {
Doctrine_Lib::getRecordAsXml($record, $xml);
}
return $xml->asXML();
}