当前位置: 首页>>代码示例>>PHP>>正文


PHP Model::getInstance方法代码示例

本文整理汇总了PHP中Model::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::getInstance方法的具体用法?PHP Model::getInstance怎么用?PHP Model::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model的用法示例。


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

示例1: getInstance

 /**
  * Get the Bootstrap static object
  *
  * @return self
  */
 public static function getInstance()
 {
     if (!isset(self::$_Command)) {
         self::$_Command = parent::getInstance();
     }
     return self::$_Command;
 }
开发者ID:dianadevargas,项目名称:php-framework,代码行数:12,代码来源:commandHandler.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     // Using factory
     // Getting an instance of a model User example
     $user = ModelFactory::getInstance('User');
     // Getting an instance of a Library String
     $stringLib = LibraryFactory::getInstance('String');
     // Getting an instance of a Filter DateRange
     $dateRange = FilterFactory::getInstance('DateRange');
     // Getting an instance of a Type User
     $userType = TypeFactory::getInstance('User');
     // Perform an access check
     AccessCheckFactory::getInstance('User')->canAccess(auth()->user()->id, 'view');
     // Using facade
     // Getting an instance of a model User example
     $user = \Model::getInstance('User');
     // Getting an instance of a Library String
     $stringLib = \Library::getInstance('String');
     // Getting an instance of a Filter DateRange
     $dateRange = \Filter::getInstance('DateRange');
     // Getting an instance of a Type User
     $userType = \Type::getInstance('User');
     // Passing data to view example
     $this->view->fullname = auth()->user()->fullname;
     // Perform an access check
     \AccessCheck::getInstance('User')->canAccess(1, 'view');
     return $this->view('dashboard');
 }
开发者ID:atudz,项目名称:gorabelframework,代码行数:33,代码来源:MainPresenter.php

示例3: retrieve

 static function retrieve(Criteria $criteria)
 {
     if (!self::$DB) {
         self::$DB = new MySQL();
     }
     $schema = self::getSchema($criteria->from_model_name);
     $relationships = $schema->getRelationships();
     foreach ($relationships as $rel) {
         $criteria->addJoin($rel->foreignModel, "{$criteria->from_model_name}.{$rel->name}", "{$rel->foreignModel}.{$rel->foreignKey}", Criteria::LEFT_JOIN);
     }
     $sql = self::getSelectString($criteria);
     $rs = self::$DB->query($sql);
     $model_array = array();
     while ($data = self::$DB->fetch($rs)) {
         $model = Model::getInstance($criteria->from_model_name);
         self::hydrateModel($model, $data);
         foreach ($relationships as $relationship) {
             $foreignModel_name = $relationship->foreignModel;
             $model->{$foreignModel_name} = Model::getInstance($foreignModel_name);
             self::hydrateModel($model->{$foreignModel_name}, $data);
         }
         $model_array[] = $model;
     }
     return $model_array;
 }
开发者ID:rev087,项目名称:kennel,代码行数:25,代码来源:ORM.php

示例4: getInstance

 /**
  * Get the context static object
  *
  * @return self
  */
 public static function getInstance()
 {
     if (!isset(self::$_Request)) {
         self::$_Request = parent::getInstance();
     }
     return self::$_Request;
 }
开发者ID:dianadevargas,项目名称:php-framework,代码行数:12,代码来源:request.php

示例5: display

 public function display($tpl = null)
 {
     Model::addIncludePath(JPATH_BASE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_menus' . DIRECTORY_SEPARATOR . 'models');
     $model = Model::getInstance('Menus', 'MenusModel');
     $this->menutypes = $model->getItems();
     $this->menu = JApplication::getInstance('site')->getMenu();
     parent::display($tpl);
 }
开发者ID:ursbraem,项目名称:staticcontent,代码行数:8,代码来源:view.html.php

示例6: getInstance

 public static function getInstance($args = null)
 {
     if (!isset($args['class'])) {
         $args['class'] = 'Logger';
     }
     if (!isset($args['db'])) {
         $args['db'] = LOG_IRI;
     }
     return parent::getInstance($args);
 }
开发者ID:nexgenta,项目名称:log,代码行数:10,代码来源:model.php

示例7: getInstance

 public static function getInstance($args = null)
 {
     if (!isset($args['class'])) {
         $args['class'] = 'LensModule';
     }
     if (!isset($args['db'])) {
         $args['db'] = LENS_IRI;
     }
     return Model::getInstance($args);
 }
开发者ID:nexgenta,项目名称:lens,代码行数:10,代码来源:module.php

示例8: getModel

 public function getModel($name = '', $prefix = '', $config = array())
 {
     require_once 'model.php';
     if (!$name) {
         $class = get_class($this);
         list($_prefix, $name) = explode('View', $class);
         $prefix = $_prefix . 'Model';
     }
     $model = Model::getInstance($name, $prefix, $config);
     return $model;
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:11,代码来源:view.php

示例9: checkUser

 public function checkUser($username)
 {
     $db = Model::getInstance();
     $mysqli = $db->getConnection();
     $escapedUsername = $mysqli->real_escape_string($username);
     if ($result = $mysqli->query("SELECT password FROM users WHERE username = '{$escapedUsername}' LIMIT 1")) {
         if ($result->num_rows > 0) {
             return $result;
         }
         $result->close();
     }
 }
开发者ID:kmaxat,项目名称:storefront,代码行数:12,代码来源:UserModel.php

示例10: sql

 private function sql()
 {
     $stats = Model::getInstance();
     $stats = $stats->getStats();
     $count = count($stats);
     $time = 0;
     if (is_array($stats)) {
         foreach ($stats as $stat) {
             $time += $stat['timer'];
         }
     }
     $this->debug .= "<br><div class='catrina-row'>Sql(" . $count . ")" . $time . " сек.</div>";
 }
开发者ID:scherbuk,项目名称:catrina,代码行数:13,代码来源:Debug.php

示例11: __construct

 public function __construct($source)
 {
     $storage = Model::getInstance();
     $this->_token = token_get_all($source);
     foreach ($this->_token as $key => $value) {
         if (is_array($value)) {
             $type = token_name($value[0]);
             $this->_token[$key][0] = $type;
         } else {
             $this->_token[$key] = [0 => 'T_STRUCTURE', 1 => trim($value), 2 => 0];
         }
     }
 }
开发者ID:camael24,项目名称:sohapi,代码行数:13,代码来源:Reader.php

示例12: getInstance

 public static function getInstance($args = null, $className = null)
 {
     if (null === $args) {
         $args = array();
     }
     if (!isset($args['db'])) {
         $args['db'] = HEARTBEAT_IRI;
     }
     if (null === $className) {
         $className = 'HeartbeatModel';
     }
     return Model::getInstance($args, $className);
 }
开发者ID:nexgenta,项目名称:heartbeat,代码行数:13,代码来源:model.php

示例13: placeOrder

 public function placeOrder($order)
 {
     $db = Model::getInstance();
     $mysqli = $db->getConnection();
     $escapedDepartment = $mysqli->real_escape_string($order->department);
     $escapedItem = $mysqli->real_escape_string($order->item_no);
     $escapedSize = $mysqli->real_escape_string($order->size);
     $escapedColor = $mysqli->real_escape_string($order->color);
     $sql = "INSERT INTO orders (department, item_no, size, color)\n                VALUES ('" . $escapedDepartment . "','" . $escapedItem . "','" . $escapedSize . "','" . $escapedColor . "')";
     if ($mysqli->query($sql) === TRUE) {
         echo "New record created successfully";
     } else {
         echo "Error: " . $sql . "<br>" . $mysqli->error;
     }
 }
开发者ID:kmaxat,项目名称:storefront,代码行数:15,代码来源:CatalogModel.php

示例14: init

 /**
  * 初始化
  *
  */
 public static function init()
 {
     $AlphaSession = new Session();
     $AlphaSession->lifeTime = ini_get('session.gc_maxlifetime');
     if (Config::get('session_user_LOC') == 'db') {
         $AlphaSession->handler = Model::getInstance()->db();
     } else {
         $AlphaSession->handler = Model::getInstance()->cache();
     }
     ini_set('session.save_handler', 'user');
     session_module_name('user');
     session_set_save_handler(array($AlphaSession, 'open'), array($AlphaSession, 'close'), array($AlphaSession, 'read'), array($AlphaSession, 'write'), array($AlphaSession, 'destroy'), array($AlphaSession, 'gc'));
     ini_get('session.auto_start') || session_start();
     //自动开启session,必须在session_set_save_handler后面执行
 }
开发者ID:phpdn,项目名称:framework,代码行数:19,代码来源:Session.php

示例15: getInstance

 public static function getInstance($args = null, $className = null)
 {
     if (null === $args) {
         $args = array();
     }
     if (!isset($args['db'])) {
         $args['db'] = MQ_IRI;
     }
     if (null === $className) {
         $className = 'MQModel';
         if (!strncmp($args['db'], 'http:', 5) || !strncmp($args['db'], 'https:', 6)) {
             $className = 'MQHTTPClientModel';
         }
     }
     return Model::getInstance($args, $className);
 }
开发者ID:nexgenta,项目名称:mq,代码行数:16,代码来源:model.php


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