• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP TActiveRecord类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中TActiveRecord的典型用法代码示例。如果您正苦于以下问题:PHP TActiveRecord类的具体用法?PHP TActiveRecord怎么用?PHP TActiveRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TActiveRecord类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: SyncWithDimension

 public function SyncWithDimension($sender, $param)
 {
     $cleanmodul = '';
     $SQL = "SELECT * FROM " . $this->Tedsend_tabelle->Text . " WHERE parent_id" . $this->Tedsend_tabelle->Text . " = " . $this->Tedsend_id->Text;
     $cleanmodul = preg_replace("/(^t[a-z]\\_)/", "", $this->Tedsend_tabelle->Text);
     preg_match("/(_[a-z])/", $cleanmodul, $matches);
     if (count($matches) >= 1) {
         $cleanmodul = preg_replace("/(_[a-z])/", ucfirst(substr($matches[1], 1, 1)), $cleanmodul);
     }
     $finderclass = ucfirst($cleanmodul) . "Record";
     $AllRecordsToWrite = TActiveRecord::finder($finderclass)->findAllBySql($SQL);
     $fieldToTransfer = $this->Tedsend_field->Text;
     if (count($AllRecordsToWrite) > 0) {
         foreach ($AllRecordsToWrite as $SingleRecord) {
             $criteria = new TActiveRecordCriteria();
             $criteria->Condition = 'idta_stammdaten_group = :stammdaten_group AND stammdaten_key_extern = :key_extern';
             $criteria->Parameters[':stammdaten_group'] = $this->Tedidta_stammdaten_group->Text;
             $criteria->Parameters[':key_extern'] = $this->Tedsend_tabelle->Text . $SingleRecord->{'id' . $this->Tedsend_tabelle->Text};
             $RecordToChange = StammdatenRecord::finder()->find($criteria);
             if (count($RecordToChange) == 0) {
                 $RecordToChange = new StammdatenRecord();
             }
             $RecordToChange->idta_stammdaten_group = $this->Tedidta_stammdaten_group->Text;
             $RecordToChange->stammdaten_key_extern = $this->Tedsend_tabelle->Text . $SingleRecord->{'id' . $this->Tedsend_tabelle->Text};
             $RecordToChange->stammdaten_name = $SingleRecord->{$fieldToTransfer};
             $RecordToChange->save();
             unset($RecordToChange);
         }
     }
 }
开发者ID:quantrocket,项目名称:planlogiq,代码行数:30,代码来源:ApplyToDimensionContainer.php


示例2: suggestUser

 public function suggestUser($sender, $param)
 {
     // Get the token
     $token = $param->getToken();
     // Sender is the Suggestions repeater
     $mySQL = "SELECT idtm_user,user_name FROM tm_user WHERE user_name LIKE '%" . $token . "%'";
     $sender->DataSource = PFH::convertdbObjectSuggest(TActiveRecord::finder('UserRecord')->findAllBySQL($mySQL), array('idtm_user', 'user_name'));
     $sender->dataBind();
 }
开发者ID:quantrocket,项目名称:planlogiq,代码行数:9,代码来源:orgworkspace.php


示例3: suggestOrganisation

 public function suggestOrganisation($sender, $param)
 {
     // Get the token
     $token = $param->getToken();
     // Sender is the Suggestions repeater
     $mySQL = "SELECT idtm_organisation,org_name,org_vorname FROM tm_organisation WHERE org_name LIKE '%" . $token . "%'";
     $sender->DataSource = PFH::convertdbObjectSuggest(TActiveRecord::finder('OrganisationRecord')->findAllBySQL($mySQL), array('idtm_organisation', 'org_name', 'org_vorname'));
     $sender->dataBind();
 }
开发者ID:quantrocket,项目名称:planlogiq,代码行数:9,代码来源:ImportTasks.php


示例4: test_find_by_sql_arb

    function test_find_by_sql_arb()
    {
        $sql = 'SELECT c.name as category, i.name as item
			FROM items i, categories c
			WHERE i.category_id = c.category_id LIMIT 2';
        $items = TActiveRecord::finder('SqlTest')->findBySql($sql);
        $sql = "SELECT users.*, 'hello' as another_value FROM users LIMIT 2";
        $users = TActiveRecord::finder('UserRecord2')->findBySql($sql);
        var_dump($users);
    }
开发者ID:Nurudeen,项目名称:prado,代码行数:10,代码来源:FindBySqlTestCase.php


示例5: test_finder_throw_exception_when_save

 function test_finder_throw_exception_when_save()
 {
     $obj = TActiveRecord::finder('BaseRecordTest');
     try {
         $obj->save();
         $this->fail();
     } catch (TActiveRecordException $e) {
         $this->pass();
     }
 }
开发者ID:Nurudeen,项目名称:prado,代码行数:10,代码来源:BaseActiveRecordTestCase.php


示例6: applyResultMap

 /**
  * Apply result mapping.
  * @param array a result set row retrieved from the database
  * @param object the result object, will create if necessary.
  * @return object the result filled with data, null if not filled.
  */
 protected function applyResultMap($row, &$resultObject = null)
 {
     if ($row === false) {
         return null;
     }
     $resultMapName = $this->_statement->getResultMap();
     $resultClass = $this->_statement->getResultClass();
     $obj = null;
     if ($this->getManager()->getResultMaps()->contains($resultMapName)) {
         $obj = $this->fillResultMap($resultMapName, $row, null, $resultObject);
     } else {
         if (strlen($resultClass) > 0) {
             $obj = $this->fillResultClass($resultClass, $row, $resultObject);
         } else {
             $obj = $this->fillDefaultResultMap(null, $row, $resultObject);
         }
     }
     if (class_exists('TActiveRecord', false) && $obj instanceof TActiveRecord) {
         //Create a new clean active record.
         $obj = TActiveRecord::createRecord(get_class($obj), $obj);
     }
     return $obj;
 }
开发者ID:BackupTheBerlios,项目名称:horux-svn,代码行数:29,代码来源:TMappedStatement.php


示例7: createFkObject

 /**
  * @param string active record class name.
  * @param array row data
  * @param array foreign key column names
  * @return TActiveRecord
  */
 protected function createFkObject($type, $row, $foreignKeys)
 {
     $obj = TActiveRecord::createRecord($type, $row);
     if (count($this->_association_columns) > 0) {
         $i = 0;
         foreach ($foreignKeys as $ref => $fk) {
             $obj->setColumnValue($ref, $row[$this->_association_columns[$i++]]);
         }
     }
     return $obj;
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:17,代码来源:TActiveRecordHasManyAssociation.php


示例8: getCommand

 /**
  * @param TActiveRecord $record
  * @return TDataGatewayCommand
  */
 public function getCommand(TActiveRecord $record)
 {
     $conn = $record->getDbConnection();
     $connStr = $conn->getConnectionString();
     $tableInfo = $this->getRecordTableInfo($record);
     if (!isset($this->_commandBuilders[$connStr])) {
         $builder = $tableInfo->createCommandBuilder($record->getDbConnection());
         Prado::using('System.Data.DataGateway.TDataGatewayCommand');
         $command = new TDataGatewayCommand($builder);
         $command->OnCreateCommand[] = array($this, 'onCreateCommand');
         $command->OnExecuteCommand[] = array($this, 'onExecuteCommand');
         $this->_commandBuilders[$connStr] = $command;
     }
     $this->_commandBuilders[$connStr]->getBuilder()->setTableInfo($tableInfo);
     $this->_currentRecord = $record;
     return $this->_commandBuilders[$connStr];
 }
开发者ID:Nurudeen,项目名称:prado,代码行数:21,代码来源:TActiveRecordGateway.php


示例9: getRecordFinder

 /**
  * @return TActiveRecord Active Record finder instance
  */
 protected function getRecordFinder()
 {
     return TActiveRecord::finder($this->getRecordClass());
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:7,代码来源:TScaffoldBase.php


示例10: findForeignKeys

 /**
  * Returns foreign keys in $fromRecord with source column names as key
  * and foreign column names in the corresponding $matchesRecord as value.
  * The method returns the first matching foreign key between these 2 records.
  * @param TActiveRecord $fromRecord
  * @param TActiveRecord $matchesRecord
  * @return array foreign keys with source column names as key and foreign column names as value.
  */
 protected function findForeignKeys($from, $matchesRecord, $loose = false)
 {
     $gateway = $matchesRecord->getRecordGateway();
     $recordTableInfo = $gateway->getRecordTableInfo($matchesRecord);
     $matchingTableName = strtolower($recordTableInfo->getTableName());
     $matchingFullTableName = strtolower($recordTableInfo->getTableFullName());
     $tableInfo = $from;
     if ($from instanceof TActiveRecord) {
         $tableInfo = $gateway->getRecordTableInfo($from);
     }
     //find first non-empty FK
     foreach ($tableInfo->getForeignKeys() as $fkeys) {
         $fkTable = strtolower($fkeys['table']);
         if ($fkTable === $matchingTableName || $fkTable === $matchingFullTableName) {
             $hasFkField = !$loose && $this->getContext()->hasFkField();
             $key = $hasFkField ? $this->getFkFields($fkeys['keys']) : $fkeys['keys'];
             if (!empty($key)) {
                 return $key;
             }
         }
     }
     //none found
     $matching = $gateway->getRecordTableInfo($matchesRecord)->getTableFullName();
     throw new TActiveRecordException('ar_relations_missing_fk', $tableInfo->getTableFullName(), $matching);
 }
开发者ID:Nurudeen,项目名称:prado,代码行数:33,代码来源:TActiveRecordRelation.php


示例11: test_finder_returns_same_instance

 function test_finder_returns_same_instance()
 {
     $obj1 = TActiveRecord::finder('BaseRecordTest');
     $obj2 = TActiveRecord::finder('BaseRecordTest');
     $this->assertSame($obj1, $obj2);
 }
开发者ID:pradosoft,项目名称:prado,代码行数:6,代码来源:BaseActiveRecordTest.php


示例12: getStartNode

 public function getStartNode($idtm_user, $modul, $planungssicht = 0)
 {
     //hier muss noch eine pruefung hin, wenn es mehrere treffer gibt...
     if (count(BerechtigungRecord::finder()->find('idtm_user = ? AND xx_modul = ?', $idtm_user, $modul)) > 0) {
         return BerechtigungRecord::finder()->find('idtm_user = ? AND xx_modul = ?', $idtm_user, $modul)->xx_id;
     } else {
         $SQL = "SELECT id" . $modul . " FROM " . $modul . " WHERE parent_id" . $modul . " = 0";
         if ($planungssicht > 0) {
             $SQL .= " AND idta_stammdatensicht = " . $planungssicht;
             //gilt nur für die planung
         }
         $SQL .= " LIMIT 1";
         $cleanmodul = preg_replace("/(^t[a-z]\\_)/", "", $modul);
         preg_match("/(_[a-z])/", $cleanmodul, $matches);
         if (count($matches) >= 1) {
             $cleanmodul = preg_replace("/(_[a-z])/", ucfirst(substr($matches[1], 1, 1)), $cleanmodul);
         }
         $finderclass = ucfirst($cleanmodul) . "Record";
         $Result = TActiveRecord::finder($finderclass)->findBySql($SQL);
         if (count($Result) >= 1) {
             $tmp = "id" . $modul;
             return $Result->{$tmp};
         } else {
             return 1;
         }
     }
 }
开发者ID:quantrocket,项目名称:planlogiq,代码行数:27,代码来源:GSProcUser.php


示例13: getForeignRecordFinder

 /**
  * @return TActiveRecord corresponding relationship foreign object finder instance.
  */
 public function getForeignRecordFinder()
 {
     return TActiveRecord::finder($this->getForeignRecordClass());
 }
开发者ID:quantrocket,项目名称:planlogiq,代码行数:7,代码来源:TActiveRecordRelationContext.php


示例14: queryManyMany

 private function queryManyMany($joinTableName, $keys)
 {
     $relation = $this->relation;
     $model = TActiveRecord::model($relation->className);
     $table = $model->getTableSchema();
     $builder = $model->getCommandBuilder();
     $schema = $builder->getSchema();
     $pkTable = $this->_parent->model->getTableSchema();
     if (($joinTable = $builder->getSchema()->getTable($joinTableName)) === null) {
         throw new TDbException('The relation "' . $relation->name . '" in active record class "' . get_class($this->_parent->model) . '" is not specified correctly. The join table "' . $joinTableName . '" given in the foreign key cannot be found in the database.');
     }
     $fks = preg_split('/[\\s,]+/', $keys, -1, PREG_SPLIT_NO_EMPTY);
     if (count($fks) !== count($table->primaryKey) + count($pkTable->primaryKey)) {
         throw new TDbException('The relation "' . $relation->name . '" in active record class "' . get_class($this->_parent->model) . '" is specified with an incomplete foreign key. The foreign key must consist of columns referencing both joining tables.');
     }
     $joinCondition = array();
     $map = array();
     foreach ($fks as $i => $fk) {
         if (!isset($joinTable->columns[$fk])) {
             throw new TDbException('The relation "' . $relation->name . '" in active record class "' . get_class($this->_parent->model) . '" is specified with an invalid foreign key "' . $fk . '". There is no such column in the table "' . $joinTable->name . '".');
         }
         if (isset($joinTable->foreignKeys[$fk])) {
             list($tableName, $pk) = $joinTable->foreignKeys[$fk];
             if (!isset($joinCondition[$pk]) && $schema->compareTableNames($table->rawName, $tableName)) {
                 $joinCondition[$pk] = $table->rawName . '.' . $schema->quoteColumnName($pk) . '=' . $joinTable->rawName . '.' . $schema->quoteColumnName($fk);
             } else {
                 if (!isset($map[$pk]) && $schema->compareTableNames($pkTable->rawName, $tableName)) {
                     $map[$pk] = $fk;
                 } else {
                     throw new TDbException('The relation "' . $relation->name . '" in active record class "' . get_class($this->_parent->model) . '" is specified with an invalid foreign key "' . $fk . '". The foreign key does not point to either joining table.');
                 }
             }
         } else {
             if ($i < count($pkTable->primaryKey)) {
                 $pk = is_array($pkTable->primaryKey) ? $pkTable->primaryKey[$i] : $pkTable->primaryKey;
                 $map[$pk] = $fk;
             } else {
                 $j = $i - count($pkTable->primaryKey);
                 $pk = is_array($table->primaryKey) ? $table->primaryKey[$j] : $table->primaryKey;
                 $joinCondition[$pk] = $table->rawName . '.' . $schema->quoteColumnName($pk) . '=' . $joinTable->rawName . '.' . $schema->quoteColumnName($fk);
             }
         }
     }
     if ($joinCondition === array() || $map === array()) {
         throw new TDbException('The relation "' . $relation->name . '" in active record class "' . get_class($this->_parent->model) . '" is specified with an incomplete foreign key. The foreign key must consist of columns referencing both joining tables.');
     }
     $records = $this->_parent->records;
     $cols = array();
     foreach (is_string($pkTable->primaryKey) ? array($pkTable->primaryKey) : $pkTable->primaryKey as $n => $pk) {
         $name = $joinTable->rawName . '.' . $schema->quoteColumnName($map[$pk]);
         $cols[$name] = $name . ' AS ' . $schema->quoteColumnName('c' . $n);
     }
     $keys = array_keys($records);
     if (is_array($pkTable->primaryKey)) {
         foreach ($keys as &$key) {
             $key2 = unserialize($key);
             $key = array();
             foreach ($pkTable->primaryKey as $pk) {
                 $key[$map[$pk]] = $key2[$pk];
             }
         }
     }
     $where = empty($relation->condition) ? '' : ' WHERE (' . $relation->condition . ')';
     $group = empty($relation->group) ? '' : ', ' . $relation->group;
     $having = empty($relation->having) ? '' : ' AND (' . $relation->having . ')';
     $order = empty($relation->order) ? '' : ' ORDER BY ' . $relation->order;
     $sql = 'SELECT ' . $this->relation->select . ' AS ' . $schema->quoteColumnName('s') . ', ' . implode(', ', $cols) . ' FROM ' . $table->rawName . ' INNER JOIN ' . $joinTable->rawName . ' ON (' . implode(') AND (', $joinCondition) . ')' . $where . ' GROUP BY ' . implode(', ', array_keys($cols)) . $group . ' HAVING (' . $builder->createInCondition($joinTable, $map, $keys) . ')' . $having . $order;
     $command = $builder->getDbConnection()->createCommand($sql);
     if (is_array($relation->params)) {
         $builder->bindValues($command, $relation->params);
     }
     $stats = array();
     foreach ($command->queryAll() as $row) {
         if (is_array($pkTable->primaryKey)) {
             $key = array();
             foreach ($pkTable->primaryKey as $n => $k) {
                 $key[$k] = $row['c' . $n];
             }
             $stats[serialize($key)] = $row['s'];
         } else {
             $stats[$row['c0']] = $row['s'];
         }
     }
     foreach ($records as $pk => $record) {
         $record->addRelatedRecord($relation->name, isset($stats[$pk]) ? $stats[$pk] : $this->relation->defaultValue, false);
     }
 }
开发者ID:quantrocket,项目名称:planlogiq,代码行数:87,代码来源:TActiveFinder.php


示例15: model

 /**
  * Returns the static model of the specified AR class.
  * @param string $className active record class name.
  * @return MakeOrgan the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
开发者ID:zwq,项目名称:unpei,代码行数:9,代码来源:MakeOrgan.php


示例16: getDbConnection

 /**
  * Returns the database connection used by active record.
  * By default, the "db" application component is used as the database connection.
  * You may override this method if you want to use a different database connection.
  * @return CDbConnection the database connection used by active record.
  * 
  * @TODO Get default db connection if theres none set
  * 
  */
 public function getDbConnection()
 {
     if (self::$db !== null) {
         return self::$db;
     } else {
         self::$db = Prado::getApplication()->getModule($this->getConnectionId())->getDbConnection();
         if (self::$db instanceof TDbConnection) {
             self::$db->setActive(true);
             return self::$db;
         } else {
             throw new TDbException('ActiveRecord requires a db connection.');
         }
     }
 }
开发者ID:quantrocket,项目名称:planlogiq,代码行数:23,代码来源:TActiveRecord.php


示例17: finder

 public static function finder($className = __CLASS__)
 {
     return parent::finder($className);
 }
开发者ID:quantrocket,项目名称:planlogiq,代码行数:4,代码来源:CustomMaskFieldRecord.php



注:本文中的TActiveRecord类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP TAdiantiCoreTranslator类代码示例发布时间:2022-05-23
下一篇:
PHP TAction类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap