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


PHP ORM::make方法代码示例

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


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

示例1: value

 public function value()
 {
     $id = $this->module->orm->field("id");
     $ormRel = ORM::make($this->linkTableName);
     $values = array();
     $entries = $ormRel->where($this->linkFromKeyField, "=", $id)->leftJoin($this->relationTableName, array($this->relationTableName . "." . $this->relationKeyField, "=", $this->linkTableName . "." . $this->linkToKeyField))->orderByAsc($this->relationTableName . "." . $this->relationNameField)->find();
     foreach ($entries as $entry) {
         $values[] = (int) $entry->field($this->linkToKeyField);
     }
     return $values;
 }
开发者ID:jura-php,项目名称:jura,代码行数:11,代码来源:ManyToManyField.php

示例2: __construct

 function __construct($connName = null)
 {
     if (!is_null(static::$tableName)) {
         $tableName = static::$tableName;
     } else {
         $tableName = Str::lower(preg_replace(array('/\\\\/', '/(?<=[a-z])([A-Z])/', '/__/'), array('_', '_$1', '_'), ltrim(get_class($this), '\\')));
     }
     if (is_null($connName) && !is_null(static::$connName)) {
         $connName = static::$connName;
     }
     $this->orm = ORM::make($tableName, $connName);
     $this->orm->className = get_class($this);
 }
开发者ID:jura-php,项目名称:jura,代码行数:13,代码来源:Model.php

示例3: routes

 public static function routes()
 {
     static::loadModules();
     foreach (static::$modulesObjects as $object) {
         $object->routes();
     }
     //Load login routes.. login, logoff, etc..
     Router::register("GET", "manager/api/config/", function () {
         header("Content-Type: text/javascript; charset=utf-8");
         if (Request::isLocal()) {
             if (@DB::query("select id from " . J_TP . "manager_users LIMIT 1;")->success === false) {
                 DB::query("CREATE TABLE `" . J_TP . "manager_users` (\n\t\t\t\t\t\t\t\t`id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t`name` varchar(255) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`email` varchar(255) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`typeID` int(11) unsigned NULL,\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t`username` varchar(255) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`password` varchar(40) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`active` int(11) DEFAULT NULL,\n\t\t\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
                 $user = ORM::make("manager_users");
                 $user->name = "Joy Interactive";
                 $user->email = "dev@joy-interactive.com";
                 $user->username = "joy";
                 $user->password = "202cb962ac59075b964b07152d234b70";
                 $user->typeID = 1;
                 $user->active = 1;
                 $user->save();
             }
             if (@DB::query("select id from " . J_TP . "manager_tokens LIMIT 1;")->success === false) {
                 DB::query("CREATE TABLE `" . J_TP . "manager_tokens` (\n\t\t\t\t\t\t\t\t`id` int(40) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t`userID` int(11) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`typeID` int(11) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`token` varchar(100) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`expirationDate` datetime DEFAULT NULL,\n\t\t\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
             }
         }
         $config = array();
         $config["api_url"] = URL::to("api/");
         return "window.config = " . json_encode($config);
     });
     Router::register("GET", "manager/api/structure/", function () {
         return Response::json(Structure::modules());
     });
     Router::register("POST", "manager/api/token/", function () {
         return User::generateToken();
     });
     Router::register("POST", "manager/api/token/renew/", function () {
         return User::renewToken();
     });
     Router::register("GET", "manager/api/logout/", function () {
         return User::logout();
     });
     Router::register("GET", "manager/api/customJS/", function () {
         $path = J_MANAGERPATH . "custom.js";
         if (file_exists($path)) {
             return File::get($path);
         }
     });
 }
开发者ID:jura-php,项目名称:jura,代码行数:48,代码来源:Structure.php

示例4: value

 public function value()
 {
     if (!$this->multiple) {
         $value = $this->module->orm->field($this->name);
         return $this->format($value);
     } else {
         $id = $this->module->orm->field("id");
         $ormRel = ORM::make($this->multipleTable);
         $values = array();
         $entries = $ormRel->where($this->multipleFieldFrom, "=", $id)->find();
         foreach ($entries as $entry) {
             $values[] = (int) $entry->field($this->multipleFieldTo);
         }
         return $values;
     }
 }
开发者ID:jura-php,项目名称:jura,代码行数:16,代码来源:ItemsField.php

示例5: token

 private static function token($emitError = true)
 {
     $token = Request::get("access_token", Request::post("access_token", Session::get("j_manager_token", "")));
     $result = array();
     if ($token != "") {
         $orm = ORM::make("manager_tokens")->select(array("expirationDate", "userID", "typeID"))->where("token", "=", $token)->findFirst();
         if ($orm) {
             $time = $orm->expirationDate;
             $result["token"] = $token;
             $result["expirationDate"] = $time;
             $result["userID"] = $orm->userID;
             $result["typeID"] = $orm->typeID;
             if (time() < $time) {
                 if ($emitError) {
                     $result["error"] = static::error(403, "expired_token");
                 } else {
                     $result["error"] = true;
                 }
             }
         }
     }
     if (!isset($result["token"]) || empty($token)) {
         if ($emitError) {
             $result["error"] = static::error(403, "invalid_token");
         } else {
             $result["error"] = true;
         }
     }
     return $result;
 }
开发者ID:jura-php,项目名称:jura,代码行数:30,代码来源:User.php


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