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


PHP Model::setup方法代碼示例

本文整理匯總了PHP中Phalcon\Mvc\Model::setup方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::setup方法的具體用法?PHP Model::setup怎麽用?PHP Model::setup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Phalcon\Mvc\Model的用法示例。


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

示例1: me

 /**
  * Initializer
  *
  * @param \Phalcon\Config $config Phalcon config
  * @return bool
  */
 public static function me(\Phalcon\Config $config)
 {
     // validate biller in config
     if (!isset($config['biller'])) {
         throw new \Exception('Entry for "biller" not found on config');
     }
     // validate stripe key
     if (!isset($config['biller']['key'])) {
         throw new \Exception('Stripe key not found on config');
     }
     // setup the stripe key
     \Stripe\Stripe::setApiKey($config['biller']['key']);
     // throw exceptions for customer, subscriptions models
     \Phalcon\Mvc\Model::setup(['exceptionOnFailedSave' => true]);
 }
開發者ID:frangeris,項目名稱:biller,代碼行數:21,代碼來源:Gateway.php

示例2:

/**
 * 特權商品
 */
namespace Gcproinfo\Models;

use Xz\Lib\Hbase\HbaseRead;
/**
 * Class pd_specialpro
 *
 *
 * @method public Pdinfo initialize()
 * @method public Pdinfo getSource()
 *
 * @package Xz\wwwtasks\Models\Gcproinfo
 */
\Phalcon\Mvc\Model::setup(array('notNullValidations' => false));
class Mspecialpro extends \Phalcon\Mvc\Model
{
    /**
     * @Primary
     * @Identity
     * @Column(type="integer", nullable=true)
     */
    public $id;
    /**
     * @Column(type="integer", nullable=true)
     */
    public $pid;
    /**
     * @Column(type="integer", nullable=true)
     */
開發者ID:tianyunchong,項目名稱:php,代碼行數:31,代碼來源:Mspecialpro.php

示例3: function

<?php

use Phalcon\Loader, Phalcon\Mvc\Model, Phalcon\Mvc\Url, Phalcon\Crypt, Phalcon\Mvc\View\Engine\Volt, Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter, Phalcon\Logger\Multiple as MultipleStreamLogger, Phalcon\Logger\Adapter\File as FileLogger, Phalcon\Logger\Adapter\Firephp as FirephpLogger, Webird\Module, Webird\Mvc\View\Simple as ViewSimple, Webird\Acl\Acl, Webird\DatabaseSessionReader, Webird\Locale\Locale, Webird\Locale\Gettext, Webird\Mailer\Manager as MailManager, Webird\Logger\Adapter\Error as ErrorLogger, Webird\Logger\Adapter\Firelogger;
/**
 *
 */
Model::setup(['phqlLiterals' => false, 'notNullValidations' => false]);
/**
 *
 */
$di->set('loader', function () use($config) {
    $commonDir = $config->path->commonDir;
    $modulesDir = $config->path->modulesDir;
    $loader = new Loader();
    $loader->setExtensions(['php']);
    $loader->registerNamespaces(['Webird\\Models' => "{$commonDir}/models", 'Webird\\Forms' => "{$commonDir}/forms", 'Webird\\Plugins' => "{$commonDir}/plugins", 'Webird' => "{$commonDir}/library"]);
    $loader->register();
    $classes = [];
    foreach ($config->app->modules as $moduleName) {
        $class = 'Webird\\' . ucfirst($moduleName) . '\\Module';
        $path = Module::moduleNameToDir($moduleName) . 'Module.php';
        $classes[$class] = $path;
    }
    $loader->registerClasses($classes, true);
    $loader->register();
    return $loader;
});
$di->get('loader');
/**
 *
 */
開發者ID:JanOschii,項目名稱:webird,代碼行數:31,代碼來源:services.php

示例4: initialize

<?php

/**
 * Model.php
 *
 */
namespace Pails\Mvc;

use Phalcon\Di;
use Phalcon\Mvc\Model as PhalconModel;
use Phalcon\Mvc\Model\Behavior\Timestampable;
PhalconModel::setup(['exceptionOnFailedSave' => true]);
abstract class Model extends PhalconModel
{
    public function initialize()
    {
        // 自動更新時間戳字段
        $this->addBehavior(new Timestampable(['beforeValidationOnCreate' => ['field' => ['created_at', 'updated_at'], 'format' => 'Y-m-d H:i:s'], 'beforeValidationOnUpdate' => ['field' => 'updated_at', 'format' => 'Y-m-d H:i:s']]));
    }
    public static function make($data = [])
    {
        // filter empty values
        $data = array_filter($data);
        // remove auto data;
        unset($data['id']);
        unset($data['created_at']);
        unset($data['updated_at']);
        //
        $model = new static();
        $model->save($data);
    }
開發者ID:xueron,項目名稱:pails,代碼行數:31,代碼來源:Model.php

示例5:

<?php

namespace reportingtool\Models;

use Phalcon\Mvc\Model;
Model::setup(['notNullValidations' => false]);
/**
 * reportingtool\Models\Projecttypes
 * 
 */
class Projecttypes extends Model
{
    /**
     * @var integer
     */
    public $uid;
    /**
     * @var integer
     */
    public $pid = 0;
    /**
     * @var integer
     */
    public $tstamp = 0;
    /**
     * @var integer
     */
    public $crdate = 0;
    /**
     * @var integer
     */
開發者ID:phil-schreiber,項目名稱:reporting-tool,代碼行數:31,代碼來源:Projecttypes.php

示例6: array

<?php

namespace App\Model;

\Phalcon\Mvc\Model::setup(array('MODELS_PRIMARY_KEY ' => array('id')));
class Member extends \App\Model\BaseModel
{
    public $username;
    public function getSource()
    {
        return 'member';
    }
}
開發者ID:NAMEs,項目名稱:phyar-framework,代碼行數:13,代碼來源:Member.php

示例7:

<?php

\Phalcon\Mvc\Model::setup(array('events' => false, 'columnRenaming' => false));
開發者ID:aodkrisda,項目名稱:phalcon-code,代碼行數:3,代碼來源:models-3026.php

示例8: initialize

 public function initialize()
 {
     Model::setup(['exceptionOnFailedSave' => true]);
     $this->belongsTo('userid', 'nltool\\Models\\Feusers', 'uid', array('alias' => 'user'));
 }
開發者ID:phil-schreiber,項目名稱:messewebsite,代碼行數:5,代碼來源:FailedLogins.php

示例9: function

        return Provider::get('url');
    };
    $app['view'] = function () {
        return Provider::get('view');
    };
    $app['validation'] = function () {
        return Provider::get('validation');
    };
    // 404頁麵
    $app->notFound(function () use($app) {
        $app->response->setStatusCode(404, "Not Found")->sendHeaders();
        echo 'Not Found';
    });
    //設置錯誤輸出選項
    if (Provider::get('config')->env->testing) {
        ini_set('display_errors', 'On');
        error_reporting(E_ALL);
    } else {
        ini_set('display_errors', 'Off');
        error_reporting(0);
    }
    //關閉Phalcon模型特性, notNullValidations特性會嚴格審查NotNull
    Model::setup(array('columnRenaming' => false, 'notNullValidations' => false, 'virtualForeignKeys' => false, 'phqlLiterals' => false));
    // 載入路由規則
    require APP_PATH . 'front_routes.php';
    require APP_PATH . 'api_routes.php';
    // 處理請求
    defined('TEST_DEBUG') or $app->handle();
} catch (Exception $e) {
    echo $e->getMessage();
}
開發者ID:sujinw,項目名稱:passport,代碼行數:31,代碼來源:bootstrap.php

示例10: define

<?php

define('APP_START_TIME', microtime(true));
define('DOCROOT', dirname(__FILE__) . '/');
require_once DOCROOT . '../vendor/autoload.php';
class_alias('Rj\\TestView124', 'TestView');
$loader = new Phalcon\Loader();
$loader->registerDirs([__DIR__ . '/models', __DIR__ . '/classes', __DIR__ . '/controllers', __DIR__ . '/forms', __DIR__ . '/tasks']);
$loader->register();
if (!isset($di)) {
    $di = new Phalcon\DI\FactoryDefault\CLI();
}
\Phalcon\Mvc\Model::setup(['notNullValidations' => false]);
$di->set('config', function () {
    /** @var Phalcon\Config $default */
    $config = (require __DIR__ . '/config/config.default.php');
    $config->merge(require __DIR__ . '/config/config.php');
    return $config;
}, true);
function logException(Exception $e, $mail = true)
{
    Logger::messages()->exception($e);
    if (Config::instance()->production) {
        if (Phalcon\DI::getDefault()->has('request')) {
            /** @var \Phalcon\Http\Request $request */
            $request = Phalcon\DI::getDefault()->getShared('request');
            $message = sprintf("%s %s: %s\n" . "UserAgent: %s\n" . "HTTP Referer: %s\n" . "%s URL: %s://%s\n" . "LoggedUser: %s\n" . "%s", date('Y-m-d H:i:s'), get_class($e), $e->getMessage(), $request->getUserAgent(), urldecode($request->getHTTPReferer()), $request->getClientAddress(), $request->getScheme(), $request->getHttpHost() . urldecode(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '<!undefined>'), $e->getTraceAsString());
        } else {
            $message = date('Y-m-d H:i:s') . ' ' . $e->getMessage() . "\n" . "There is no request object\n" . $e->getTraceAsString();
        }
        switch (true) {
開發者ID:rj28,項目名稱:executer,代碼行數:31,代碼來源:bootstrap.php

示例11: initialize

 public function initialize()
 {
     \Phalcon\Mvc\Model::setup(['notNullValidations' => false]);
     $this->checkName();
 }
開發者ID:kjmtrue,項目名稱:phanbook,代碼行數:5,代碼來源:Settings.php

示例12: initialize

 public function initialize()
 {
     $this->keepSnapshots(true);
     $this->useDynamicUpdate(true);
     MvcModel::setup(['ignoreUnknownColumns' => true]);
 }
開發者ID:denners777,項目名稱:api-phalcon,代碼行數:6,代碼來源:ModelBase.php

示例13: setup

 public static function setup(array $options)
 {
     PhalconModel::setup($options);
     isset($options['distributed']) and static::$_distributedOptions = $options['distributed'];
 }
開發者ID:phwoolcon,項目名稱:phwoolcon,代碼行數:5,代碼來源:Model.php

示例14: run

 /**
  * 開始運行
  */
 public function run()
 {
     try {
         $this->onBefore();
         $this->initLoader();
         $this->initRouters();
         $this->initUrl();
         $this->initDatabase();
         $this->initModelsMetadata();
         $this->initCookie();
         $this->initLogger();
         $this->initShortFunc();
         \Phalcon\Mvc\Model::setup(['notNullValidations' => false]);
         $this->onAfter();
         $this->app->setDI($this->di);
         $this->registerModules();
         echo $this->app->handle()->getContent();
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
 }
開發者ID:fu-tao,項目名稱:meelier_c,代碼行數:24,代碼來源:Bootstrap.php


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