本文整理汇总了PHP中Doctrine_Table类的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Table类的具体用法?PHP Doctrine_Table怎么用?PHP Doctrine_Table使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Doctrine_Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(Doctrine_Table $table, $fieldName)
{
$this->_table = $table;
$columnList = $this->_table->getColumnNames();
//Check if the identity and credential are one of the column names...
if (!in_array($fieldName, $columnList)) {
throw new Zend_Auth_Adapter_Exception("Invalid Column names are given as '{$fieldName}'");
}
$this->_fieldName = $fieldName;
}
示例2: generateClassFromTable
public function generateClassFromTable(Doctrine_Table $table)
{
$definition = array();
$definition['columns'] = $table->getColumns();
$definition['tableName'] = $table->getTableName();
$definition['actAs'] = $table->getTemplates();
$definition['generate_once'] = true;
$generatedclass = $this->generateClass($definition);
Doctrine::loadModels(sfConfig::get('sf_lib_dir') . '/model/doctrine/opCommunityTopicPlugin/base/');
return $generatedclass;
}
开发者ID:niryuu,项目名称:opCommunityTopicPlugin-100628,代码行数:11,代码来源:opCommunityTopicPluginImagesRecordGenerator.class.php
示例3: __construct
public function __construct(Doctrine_Table $table, $identityCol, $credentialCol)
{
$this->_table = $table;
$columnList = $this->_table->getColumnNames();
//Check if the identity and credential are one of the column names...
if (!in_array($identityCol, $columnList) || !in_array($credentialCol, $columnList)) {
throw new Zend_Auth_Adapter_Exception("Invalid Column names are given as '{$identityCol}' and '{$credentialCol}'");
}
$this->_credentialCol = $credentialCol;
//Assign the column names...
$this->_identityCol = $identityCol;
}
示例4: __construct
/**
* constructor
*
* @param array $options an array of plugin options
*/
public function __construct(array $options = array())
{
parent::__construct($options);
if (!isset($this->_options['resource'])) {
$table = new Doctrine_Table('File', Doctrine_Manager::connection());
$table->setColumn('url', 'string', 255, array('primary' => true));
}
if (empty($this->_options['fields'])) {
$this->_options['fields'] = array('url', 'content');
}
$this->initialize($table);
}
示例5: __construct
/**
* constructor, creates tree with reference to table and any options
*
* @param object $table instance of Doctrine_Table
* @param array $options options
*/
public function __construct(Doctrine_Table $table, $options)
{
$this->table = $table;
$this->options = $options;
$this->_baseComponent = $table->getComponentName();
$class = $this->_baseComponent;
if ($table->getOption('inheritanceMap')) {
$subclasses = $table->getOption('subclasses');
while (in_array($class, $subclasses)) {
$class = get_parent_class($class);
}
$this->_baseComponent = $class;
}
//echo $this->_baseComponent;
}
示例6: isIdentifiable
/**
* isIdentifiable
* returns whether or not a given data row is identifiable (it contains
* all primary key fields specified in the second argument)
*
* @param array $row
* @param Doctrine_Table $table
* @return boolean
*/
public function isIdentifiable(array $row, Doctrine_Table $table)
{
$primaryKeys = $table->getIdentifierColumnNames();
if (is_array($primaryKeys)) {
foreach ($primaryKeys as $id) {
if (!isset($row[$id])) {
return false;
}
}
} else {
if (!isset($row[$primaryKeys])) {
return false;
}
}
return true;
}
示例7: parseValue
public function parseValue($value, Doctrine_Table $table = null, $field = null)
{
$conn = $this->query->getConnection();
if (substr($value, 0, 1) == '(') {
// trim brackets
$trimmed = $this->_tokenizer->bracketTrim($value);
if (substr($trimmed, 0, 4) == 'FROM' || substr($trimmed, 0, 6) == 'SELECT') {
// subquery found
$q = new Doctrine_Query();
$value = '(' . $this->query->createSubquery()->parseQuery($trimmed, false)->getQuery() . ')';
} elseif (substr($trimmed, 0, 4) == 'SQL:') {
$value = '(' . substr($trimmed, 4) . ')';
} else {
// simple in expression found
$e = $this->_tokenizer->sqlExplode($trimmed, ',');
$value = array();
$index = false;
foreach ($e as $part) {
if (isset($table) && isset($field)) {
$index = $table->enumIndex($field, trim($part, "'"));
if (false !== $index && $conn->getAttribute(Doctrine::ATTR_USE_NATIVE_ENUM)) {
$index = $conn->quote($index, 'text');
}
}
if ($index !== false) {
$value[] = $index;
} else {
$value[] = $this->parseLiteralValue($part);
}
}
$value = '(' . implode(', ', $value) . ')';
}
} else {
if (substr($value, 0, 1) == ':' || $value === '?') {
// placeholder found
if (isset($table) && isset($field) && $table->getTypeOf($field) == 'enum') {
$this->query->addEnumParam($value, $table, $field);
} else {
$this->query->addEnumParam($value, null, null);
}
} else {
$enumIndex = false;
if (isset($table) && isset($field)) {
// check if value is enumerated value
$enumIndex = $table->enumIndex($field, trim($value, "'"));
if (false !== $enumIndex && $conn->getAttribute(Doctrine::ATTR_USE_NATIVE_ENUM)) {
$enumIndex = $conn->quote($enumIndex, 'text');
}
}
if ($enumIndex !== false) {
$value = $enumIndex;
} else {
$value = $this->parseLiteralValue($value);
}
}
}
return $value;
}
示例8: getRecord
/**
* get product object of class depending on object properties itself
*
* @see vendor/doctrine/Doctrine/Doctrine_Table::getRecord()
*
* @return tpyProduct
*/
public function getRecord()
{
$basic_product = parent::getRecord();
if (0 == strlen($basic_product->getClassName()) or $basic_product->getClassName() == get_class($basic_product)) {
return $basic_product;
}
$class_name = $basic_product->getClassName();
$special_product = new $class_name($this, false);
$special_product->setDoctrineRecord($basic_product);
return $special_product;
}
示例9: getQuery
/**
* Return a query object, creating a new one if needed.
*
* @param Doctrine_Query $query
* @return Doctrine_Query
*/
public function getQuery(Doctrine_Query $query = null)
{
if (is_null($query)) {
$query = parent::createQuery('variation');
}
return $query;
}
示例10: delete
/**
* Deletes all records from this collection
*
* @return Doctrine_Collection
*/
public function delete(Doctrine_Connection $conn = null, $clearColl = true)
{
if ($conn == null) {
$conn = $this->_table->getConnection();
}
try {
$conn->beginInternalTransaction();
$conn->transaction->addCollection($this);
foreach ($this as $key => $record) {
$record->delete($conn);
}
$conn->commit();
} catch (Exception $e) {
$conn->rollback();
throw $e;
}
if ($clearColl) {
$this->clear();
}
return $this;
}
示例11: _write
/**
* Write Event to database
*
* @param array $event
*/
public function _write($event)
{
$entry = $this->_table->create(array());
foreach ($this->_columnMap as $eventIndex => $tableColumn) {
$entry->{$tableColumn} = $event[$eventIndex];
}
$entry->save();
}
示例12: createQuery
public function createQuery($alias = '')
{
//By default, collection is ordered by length descending. This prevents word overlap
// ex: 'my word' will match before 'word'. More "specific" Hyperwords match first
$q = parent::createQuery($alias);
$q->select('*, LENGTH(name) as length')->orderBy('length DESC');
return $q;
}
示例13: __construct
/**
*
*@throws Doctrine_Connection_Exception if there are no opened connections
*@param Doctrine_Connection $conn the connection associated with this table
*/
public function __construct(Doctrine_Connection $conn = null)
{
if ($conn === null) {
$conn = Doctrine_Manager::connection();
}
$name = str_replace('App_Table_', '', get_class($this));
parent::__construct($name, $conn, true);
}
示例14: indexAction
/**
* Our index action, show a lab.
*/
public function indexAction()
{
$this->view->headScript()->appendFile("/js/taffydb/taffy.js")->appendFile("/js/labs/views/task.js")->appendFile("/js/labs/models/task.js")->appendFile("/js/labs/controllers/add_task.js")->appendFile("/js/labs/controllers/task_list.js");
// Check for a code
if (!$this->_request->has("code")) {
throw new Exception(self::ERROR_NO_CODE, 404);
}
// get the passed code
$code = $this->_request->getParam("code");
$lab = $this->db->findOneByCode($code);
// check if the code is valid
if (!$lab instanceof App_Db_Lab) {
throw new Exception(self::ERROR_INVALID_CODE, 404);
}
$this->view->lab = $lab;
$this->view->headTitle($lab->name);
}
示例15: getExportableFormat
/**
* Before returning the exportable-version of this table, unset any foreign
* keys that had the option "export => false".
*
* @param bool $parseForeignKeys
* @return array
*/
public function getExportableFormat($parseForeignKeys = true)
{
$data = parent::getExportableFormat($parseForeignKeys);
// unset any fk's that we shouldn't export
foreach ($this->no_export as $rel_alias) {
$key_name = $this->getRelation($rel_alias)->getForeignKeyName();
unset($data['options']['foreignKeys'][$key_name]);
}
return $data;
}