本文整理汇总了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;
}
示例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');
}
示例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;
}
示例4: getInstance
/**
* Get the context static object
*
* @return self
*/
public static function getInstance()
{
if (!isset(self::$_Request)) {
self::$_Request = parent::getInstance();
}
return self::$_Request;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
}
示例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>";
}
示例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];
}
}
}
示例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);
}
示例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;
}
}
示例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后面执行
}
示例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);
}