当前位置: 首页>>代码示例>>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;未经允许,请勿转载。