當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LSActiveRecord類代碼示例

本文整理匯總了PHP中LSActiveRecord的典型用法代碼示例。如果您正苦於以下問題:PHP LSActiveRecord類的具體用法?PHP LSActiveRecord怎麽用?PHP LSActiveRecord使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了LSActiveRecord類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: model

 /**
  * Returns the static model of ParticipantAttributeName table
  *
  * @static
  * @access public
  * @param string $class
  * @return ParticipantAttributeName
  */
 public static function model($class = __CLASS__)
 {
     $model = parent::model($class);
     $keys = $model->tableSchema->primaryKey;
     if (is_array($keys) && count($keys) == 2) {
         // Fix the primary key, needed for PgSQL http://bugs.limesurvey.org/view.php?id=6707
         // First load the helper
         Yii::app()->loadHelper('update/updatedb');
         $dbType = setsDBDriverName();
         setVarchar($dbType);
         $table = 'participant_attribute_names';
         if ($dbType == 'mysql') {
             // Only for mysql first remove auto increment
             alterColumn($model->tableName(), $model->primaryKey(), $model->tableSchema->getColumn($model->primaryKey())->dbType, false);
         }
         dropPrimaryKey($table);
         addPrimaryKey($table, (array) $model->primaryKey());
         if ($dbType == 'mysql') {
             // Add back auto increment
             alterColumn($model->tableName(), $model->primaryKey(), Yii::app()->getConfig('autoincrement'));
         }
         // Refresh all schema data now just to make sure
         Yii::app()->db->schema->refresh();
         $model->refreshMetaData();
     }
     return $model;
 }
開發者ID:jdbaltazar,項目名稱:survey-office,代碼行數:35,代碼來源:ParticipantAttributeName.php

示例2: model

 /**
  * Returns the static model of Settings table
  *
  * @static
  * @access public
  * @param int $surveyid
  * @return Tokens_dynamic
  */
 public static function model($sid = null)
 {
     if (!is_null($sid)) {
         self::sid($sid);
     }
     return parent::model(__CLASS__);
 }
開發者ID:rawaludin,項目名稱:LimeSurvey,代碼行數:15,代碼來源:Tokens_dynamic.php

示例3: __construct

 /**
  * @param string $scenario
  * @param int $iSurveyId
  */
 public function __construct($iSurveyId = null, $scenario = 'insert')
 {
     if (!isset($iSurveyId)) {
         $iSurveyId = Response::getLastSurveyId();
     }
     $this->surveyId = $iSurveyId;
     parent::__construct($scenario);
 }
開發者ID:mfavetti,項目名稱:LimeSurvey,代碼行數:12,代碼來源:Timing.php

示例4: model

 /**
  *
  * @param type $className
  * @return Dynamic
  */
 public static function model($className = null)
 {
     if (!isset($className)) {
         $className = get_called_class();
     } elseif (is_numeric($className)) {
         $className = get_called_class() . '_' . $className;
     }
     return parent::model($className);
 }
開發者ID:mfavetti,項目名稱:LimeSurvey,代碼行數:14,代碼來源:Dynamic.php

示例5: __construct

 /**
  * @param string $scenario
  * @param string $sTableName
  */
 public function __construct($sTableName = null, $scenario = 'insert')
 {
     if (!isset($sTableName)) {
         //Yii::trace('sTableName missing.');
         throw new Exception('sTableName missing.');
     }
     $this->tableName = $sTableName;
     parent::__construct($scenario);
 }
開發者ID:jdbaltazar,項目名稱:survey-office,代碼行數:13,代碼來源:PluginDynamic.php

示例6: beforeDelete

 public function beforeDelete()
 {
     $city = City::model()->findAll();
     foreach ($city as $id => $item) {
         $citys = explode('|', $item->state_id);
         if (in_array($this->state_id, array_values($citys))) {
             Yii::app()->setFlashMessage('Can not delete, State in use in city master', 'error');
             return false;
         }
     }
     return parent::beforeDelete();
 }
開發者ID:jdbaltazar,項目名稱:survey-office,代碼行數:12,代碼來源:State.php

示例7: beforeDelete

 public function beforeDelete()
 {
     $suppliers = Contact::model()->findAll();
     foreach ($suppliers as $id => $item) {
         $vehicles = explode('|', $item->city_id);
         if (in_array($this->city_id, array_values($vehicles))) {
             Yii::app()->setFlashMessage('Can not delete, City in use in contact master', 'error');
             return false;
         }
     }
     return parent::beforeDelete();
 }
開發者ID:jdbaltazar,項目名稱:survey-office,代碼行數:12,代碼來源:City.php

示例8: beforeDelete

 public function beforeDelete()
 {
     $contactgroup = Contact::model()->findAll();
     foreach ($contactgroup as $id => $item) {
         $contactgroups = explode('|', $item->contact_group_id);
         if (in_array($this->contact_group_id, array_values($contactgroups))) {
             Yii::app()->setFlashMessage('Can not delete these, Contact Group, it is used in contact master', 'error');
             return false;
         }
     }
     return parent::beforeDelete();
 }
開發者ID:jdbaltazar,項目名稱:survey-office,代碼行數:12,代碼來源:Contact_group.php

示例9: beforeDelete

 public function beforeDelete()
 {
     $contact_title = getContactTitleDelete();
     foreach ($contact_title as $id => $item) {
         $contact_titles = explode('|', $item["contact_title_id"]);
         if (in_array($this->contact_title_id, array_values($contact_titles))) {
             Yii::app()->setFlashMessage('Can not delete, Contact Title in use in contact master', 'error');
             return false;
         }
     }
     return parent::beforeDelete();
 }
開發者ID:jdbaltazar,項目名稱:survey-office,代碼行數:12,代碼來源:contact_title.php

示例10: beforeDelete

 public function beforeDelete()
 {
     //        $project = projects::model()->findAll();
     //        $zone = Zone::model()->findAll();
     //        foreach ($project as $id => $item) {
     //            $projects = explode('|', $item->country_id);
     //            if (in_array($this->country_id, array_values($projects))) {
     //                Yii::app()->setFlashMessage('Can not delete, Country in use in project master', 'error');
     //                return false;
     //            }
     //        }
     return parent::beforeDelete();
 }
開發者ID:jdbaltazar,項目名稱:survey-office,代碼行數:13,代碼來源:Get_body.php

示例11: model

 /**
  * Returns the static model of Settings table
  *
  * @static
  * @access public
  * @param int $surveyid
  * @return Tokens_dynamic
  */
 public static function model($sid = NULL)
 {
     $refresh = false;
     if (!is_null($sid)) {
         self::sid($sid);
         $refresh = true;
     }
     $model = parent::model(__CLASS__);
     //We need to refresh if we changed sid
     if ($refresh === true) {
         $model->refreshMetaData();
     }
     return $model;
 }
開發者ID:ryu1inaba,項目名稱:LimeSurvey,代碼行數:22,代碼來源:Tokens_dynamic.php

示例12: findByPk

 public function findByPk($pk, $condition = '', $params = array())
 {
     if (empty($condition) && empty($params)) {
         if (array_key_exists($pk, $this->findByPkCache)) {
             return $this->findByPkCache[$pk];
         } else {
             $result = parent::findByPk($pk, $condition, $params);
             if (!is_null($result)) {
                 $this->findByPkCache[$pk] = $result;
             }
             return $result;
         }
     }
     return parent::findByPk($pk, $condition, $params);
 }
開發者ID:jdbaltazar,項目名稱:survey-office,代碼行數:15,代碼來源:Rectify.php

示例13: model

 /**
  * Returns the static model of Settings table
  *
  * @static
  * @access public
  * @param string $class
  * @return Answer
  */
 public static function model($class = __CLASS__)
 {
     return parent::model($class);
 }
開發者ID:jdbaltazar,項目名稱:survey-office,代碼行數:12,代碼來源:Answer.php

示例14: beforeSave

 /**
  * This method is invoked before saving a record (after validation, if any).
  * The default implementation raises the {@link onBeforeSave} event.
  * You may override this method to do any preparation work for record saving.
  * Use {@link isNewRecord} to determine whether the saving is
  * for inserting or updating record.
  * Make sure you call the parent implementation so that the event is raised properly.
  * @return boolean whether the saving should be executed. Defaults to true.
  */
 public function beforeSave()
 {
     // Postgres delivers bytea fields as streams :-o - if this is not done it looks like Postgres saves something unexpected
     if ($this->usesleft > 0) {
         $this->completed = 'N';
     }
     return parent::beforeSave();
 }
開發者ID:pmaonline,項目名稱:limesurvey-quickstart,代碼行數:17,代碼來源:Tokens_dynamic.php

示例15: beforeSave

 /**
  * Make sure we don't save a new question group
  * while the survey is active.
  *
  * @return bool
  */
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         $surveyIsActive = Survey::model()->findByPk($this->sid)->active !== 'N';
         if ($surveyIsActive && $this->getIsNewRecord()) {
             return false;
         }
         return true;
     } else {
         return false;
     }
 }
開發者ID:sickpig,項目名稱:LimeSurvey,代碼行數:18,代碼來源:Question.php


注:本文中的LSActiveRecord類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。