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

PHP BaseModel类代码示例

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

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



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

示例1: addToFieldLayout

 /**
  * Append a field to a source's fieldlayout programmatically.
  *
  * @param BaseModel  $source  The element's source (e.g. a EntryTypeModel or CategoryGroupModel)
  * @param FieldModel $field   The field's model
  * @param int        $index   The index of the field on the tab (optional - defaults to 0)
  * @param string     $tabName The fieldlayout's tab (optional)
  */
 public static function addToFieldLayout(BaseModel $source, FieldModel $field, $index = 0, $tabName = '')
 {
     // Assemble layout array
     $layout = array($tabName => array());
     // Get fieldlayout
     $fieldlayout = $source->getFieldLayout();
     // Get element type
     $elementType = $source->elementType;
     // Get field layout tabs
     $fieldlayouttabs = $fieldlayout->getTabs();
     // Loop through tabs
     foreach ($fieldlayouttabs as $tab) {
         // Gather tab fields for assembly
         $layout[$tab->name] = array();
         // Get tab fields
         $tabfields = $tab->getFields();
         // Loop through tab fields
         foreach ($tabfields as $tabfield) {
             // Gather field id's
             $layout[$tab->name][] = $tabfield->getField()->id;
         }
     }
     // Add the new fields to the tab
     array_splice($layout[$tabName], $index, 0, $field->id);
     // Asemble the layout
     // @TODO - Set required fields
     $assembledLayout = craft()->fields->assembleLayout($layout, array());
     $assembledLayout->type = $elementType;
     // Set the assembled layout on the company
     $source->setFieldLayout($assembledLayout);
 }
开发者ID:boboldehampsink,项目名称:migrationshelper,代码行数:39,代码来源:MigrationsHelper.php


示例2: addToFieldLayout

 /**
  * Append a field to a source's fieldlayout programmatically.
  *
  * @param string     $elementType The fieldlayout's Element Type
  * @param BaseModel  $source      The element's source (e.g. a EntryTypeModel or CategoryGroupModel)
  * @param FieldModel $field       The field's model
  * @param string     $tabName     The fieldlayout's tab
  *
  * @return BaseModel
  */
 public static function addToFieldLayout($elementType, BaseModel $source, FieldModel $field, $tabName)
 {
     // Assemble layout array
     $layout = array();
     // Get fieldlayout
     $fieldlayout = $source->getFieldLayout();
     // Get field layout tabs
     $fieldlayouttabs = $fieldlayout->getTabs();
     // Loop through tabs
     foreach ($fieldlayouttabs as $tab) {
         // Gather tab fields for assembly
         $layout[$tab->name] = array();
         // Get tab fields
         $tabfields = $tab->getFields();
         // Loop through tab fields
         foreach ($tabfields as $tabfield) {
             // Gather field id's
             $layout[$tab->name][] = $tabfield->getField()->id;
         }
     }
     // Add the new fields to the tab
     $layout[$tabName][] = $field->id;
     // Asemble the layout
     $assembledLayout = craft()->fields->assembleLayout($layout, array());
     $assembledLayout->type = $elementType;
     // Set the assembled layout on the company
     $source->setFieldLayout($assembledLayout);
     // Return source
     return $source;
 }
开发者ID:bvangennep,项目名称:migrationshelper,代码行数:40,代码来源:MigrationsHelper.php


示例3: delete

 /**
  * Delete a model.
  *
  * @param BaseModel $model
  */
 public function delete($model, $flush = true)
 {
     $this->getDispatcher()->dispatch('model_before_delete', new ModelEvent($model, $this->getContainer()));
     $this->getDispatcher()->dispatch($model->getEventPrefix() . '_before_delete', new ModelEvent($model, $this->getContainer()));
     $this->_delete($model, $flush);
     $this->getDispatcher()->dispatch('model_after_delete', new ModelEvent($model, $this->getContainer()));
     $this->getDispatcher()->dispatch($model->getEventPrefix() . '_after_delete', new ModelEvent($model, $this->getContainer()));
 }
开发者ID:nietzcheson,项目名称:symfony,代码行数:13,代码来源:ModelManager.php


示例4: sql

 static function sql($sql)
 {
     if (!$sql) {
         return false;
     }
     $model = new BaseModel();
     $result = $model->sql($sql);
     return $result;
 }
开发者ID:jianchengdu,项目名称:dangjia,代码行数:9,代码来源:BaseData.php


示例5: getTranslatedDefinition

 /**
  * Returns the translated definition for the word hatred
  *
  * {Injects a static method dependency for Craft::t}
  *
  * @param	string	$translator	The name of the static class that defines t()
  *
  * @return	string
  */
 public function getTranslatedDefinition(BaseModel $model)
 {
     if ($model->validate()) {
         // Static method dependencies are just not elegant to work with
         // We can use $model->property but using $model->getAttribute('property') make this method more testable
         return call_user_func_array($this->translator . '::t', array($model->getAttribute('definition')));
     }
     return false;
 }
开发者ID:webremote,项目名称:craft.loath,代码行数:18,代码来源:LoathService.php


示例6: renderObjectContentSafely

 /**
  * @param BaseModel $model
  * @param array|mixed $obj
  */
 public function renderObjectContentSafely(&$model, $obj)
 {
     $content = $model->getContent();
     foreach ($content as $attribute => $value) {
         if (is_string($value) && stripos($value, '{') !== false) {
             $model->getContent()->{$attribute} = $this->renderObjectTemplateSafely($value, $obj);
         }
     }
 }
开发者ID:jackmcgreevy,项目名称:fast,代码行数:13,代码来源:SproutEmailService.php


示例7: onStore

 /**
  * Perform actions after new user has been stored
  * @param  BaseModel $user User that has just been stored
  */
 public function onStore($user)
 {
     // Make the first user SuperAdmin
     if (count(User::all()) == 1 && !$user->hasRole('Super Admin')) {
         $user->roles()->attach(Role::where('name', '=', 'Super Admin')->firstOrFail());
         Log::debug(e($user->username) . ': Assigning "Super Admin" role as first user to log in', [$user->api_key]);
     }
     // Generate an API key if the user does not have one
     if (empty($user->api_key)) {
         $user->api_key = md5(str_random(32));
         $user->save();
         Log::debug(e($user->username) . ': Generating API key', [$user->api_key]);
     }
 }
开发者ID:PoxyDoxy,项目名称:lanager,代码行数:18,代码来源:UserHandler.php


示例8: __construct

 /**
  * 获取分表中的表名,获取数据库抽象类对象,获取Memcached抽象对象
  * @param $pid
  */
 function __construct($pid = '', $persister = false)
 {
     parent::__construct($pid);
     $this->dbConfig = BaseModel::getConfigVar('database');
     //v($this->dbConfig);
     $this->setTable();
     $dbName = "default";
     $child_classname = get_class($this);
     if (isset($this->dbConfig['config_map_class'])) {
         foreach ($this->dbConfig['config_map_class'] as $key => $row) {
             if (in_array($child_classname, $row)) {
                 $dbName = $key;
                 break;
             }
         }
     }
     $this->dbName = $dbName;
     //Slave数据库预连接
     if (empty($this->slaveDB)) {
         $this->slaveDB = $this->dbConnect($dbName, $persister);
     }
     //var_dump($this->slaveDB);
     if (empty($this->masterDB)) {
         $this->masterDB = $this->dbMasterConnect($dbName, $persister);
         //Master数据库预连接
     }
 }
开发者ID:weichaoduo,项目名称:zeromore,代码行数:31,代码来源:BaseDBModel.php


示例9: __construct

 function __construct($con, $config, $routes)
 {
     $this->con = $con;
     $this->config = $config;
     $this->routes = $routes;
     BaseModel::$con = $con;
 }
开发者ID:medo,项目名称:elmasla7a,代码行数:7,代码来源:App.php


示例10: setAttribute

 /**
  * @inheritDoc BaseModel::setAttribute()
  *
  * @param string $name
  * @param mixed  $value
  *
  * @return bool|null
  */
 public function setAttribute($name, $value)
 {
     if ($name == 'releases') {
         $value = PluginNewReleaseModel::populateModels($value);
     }
     parent::setAttribute($name, $value);
 }
开发者ID:paulcarvill,项目名称:Convergence-craft,代码行数:15,代码来源:PluginUpdateModel.php


示例11: setAttribute

 /**
  * @inheritDoc BaseModel::setAttribute()
  *
  * @param string $name
  * @param mixed  $value
  *
  * @return bool|null
  */
 public function setAttribute($name, $value)
 {
     if ($name == 'plugins') {
         $value = PluginUpdateModel::populateModels($value);
     }
     parent::setAttribute($name, $value);
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:15,代码来源:UpdateModel.php


示例12: boot

 /**
  * The "booting" method of the model.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::saving(function ($item) {
         $item->key = hash('sha512', microtime() . rand());
     });
 }
开发者ID:AccessibilityNL,项目名称:User-Testing-Tool,代码行数:12,代码来源:Organization.php


示例13:

 function export_to_db()
 {
     $array = parent::export_to_db();
     $array["includes_tshirt"] = self::bool_to_db($this->includes_tshirt);
     $array["available_at_door"] = self::bool_to_db($this->available_at_door);
     return $array;
 }
开发者ID:epochwolf,项目名称:kairos,代码行数:7,代码来源:registration_level.php


示例14: __construct

 public function __construct($pixie)
 {
     parent::__construct($pixie);
     $this->created_at = date('Y-m-d H:i:s');
     $this->status = self::STATUS_NEW;
     $this->amount = 0;
 }
开发者ID:nchervyakov,项目名称:evolve2,代码行数:7,代码来源:Order.php


示例15: __construct

 public function __construct($id = -1)
 {
     parent::__construct();
     $q = "SELECT * FROM RiskMitigationPlan WHERE id = {$id}";
     $db = new Dbase();
     $res = $db->executeQuery($q);
     if ($res && $res->num_rows > 0) {
         if ($row = $res->fetch_assoc()) {
             $this->id = $row['id'];
             $this->prelaunch_checklist = $row['prelaunch_checklist'];
             $this->UAT_required = $row['UAT_required'];
             $this->UAT_conducted_by = $row['UAT_conducted_by'];
             $this->UAT_date = $row['UAT_date'];
             $this->vetted_by_stakeholders = $row['vetted_by_stakeholders'];
             $this->feedback_taken_from = $row['feedback_taken_from'];
             $this->feedback = $row['feedback'];
             $this->feedback_incorporated = $row['feedback_incorporated'];
             $this->feedback_incorporation_date = $row['feedback_incorporation_date'];
             $this->final_UAT = $row['final_UAT'];
             $this->final_UAT_conducted_by = $row['final_UAT_conducted_by'];
             $this->final_sign_off = $row['final_sign_off'];
             $this->GTM_sign_off = $row['GTM_sign_off'];
             $this->SVP_sign_off = $row['SVP_sign_off'];
         }
     }
     $res->free();
 }
开发者ID:pallavdiablo,项目名称:Panorama,代码行数:27,代码来源:model.RiskMitigationPlan.php


示例16: getAttributeConfigs

 /**
  * Returns this model's normalized attribute configs.
  *
  * @return array
  */
 public function getAttributeConfigs()
 {
     if (!isset($this->_attributeConfigs)) {
         $this->_attributeConfigs = parent::getAttributeConfigs();
     }
     return $this->_attributeConfigs;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:12,代码来源:ContentModel.php


示例17: setAttribute

 public function setAttribute($name, $value)
 {
     parent::setAttribute($name, $value);
     if (in_array($name, $this->attributeNames())) {
         $attributes = $this->getAttributeConfigs();
         $config = $attributes[$name];
         // Handle special case attribute types
         switch ($config['type']) {
             case AttributeType::Bool:
                 if ($value) {
                     $value = (bool) $value;
                 }
                 break;
             case AttributeType::Number:
                 if ($value) {
                     $value = floatval(number_format($value, $config['decimals']));
                 }
                 break;
         }
         $this->{$name} = $value;
         return true;
     } else {
         return false;
     }
 }
开发者ID:jwc2790,项目名称:Craft-Plugin-Starter,代码行数:25,代码来源:PluginModel.php


示例18: canEdit

 function canEdit($user)
 {
     if (parent::canEdit($user)) {
         return true;
     }
     if ($user) {
         // User created comment
         $this->user->get();
         if ($this->user) {
             if ($this->user->id == $user->id) {
                 return true;
             }
         }
         // User owns comment's entry
         $this->entry->get();
         if ($this->entry) {
             $this->entry->user->get();
             if ($this->entry->user) {
                 if ($user->id == $this->entry->user->id) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:broofa,项目名称:socipedia,代码行数:26,代码来源:comment.php


示例19: Index

 public function Index()
 {
     parent::GetAccountInfo();
     //get all commands
     $sql = "SELECT * FROM commands";
     if ($stmt = $this->database->prepare($sql)) {
         $stmt->execute();
         $row = $stmt->fetchAll(PDO::FETCH_ASSOC);
         $this->view->commands = $row;
         $stmt->closeCursor();
     }
     //get current state command id
     $command_id = null;
     $sql = "SELECT command_id FROM state LIMIT 1";
     if ($stmt = $this->database->prepare($sql)) {
         $stmt->execute();
         $row = $stmt->fetch(PDO::FETCH_ASSOC);
         $command_id = $row['command_id'];
         $stmt->closeCursor();
     }
     //get current command
     $sql = "SELECT * FROM commands WHERE id=:command_id";
     if ($stmt = $this->database->prepare($sql)) {
         $stmt->bindParam(':command_id', $command_id, PDO::PARAM_STR);
         $stmt->execute();
         $row = $stmt->fetch(PDO::FETCH_ASSOC);
         $this->view->current_command = $row;
         $stmt->closeCursor();
     }
 }
开发者ID:RydoSmith,项目名称:BNet,代码行数:30,代码来源:dashboardmodel.php


示例20: initialize

 public function initialize()
 {
     parent::initialize();
     $database = new Elements();
     $database = $database->getDatabase();
     $this->setConnectionService($database);
 }
开发者ID:qcww,项目名称:yh_cms,代码行数:7,代码来源:CustomBase.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP BaseObject类代码示例发布时间:2022-05-23
下一篇:
PHP BaseMemberControl类代码示例发布时间: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