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


PHP Objects::objects方法代码示例

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


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

示例1: by_model

 /**
  * 
  * @param Model $model
  * @param Objects $object
  * @return Objects
  */
 public static function by_model(Model $model, Objects &$object = null, $prefix = null)
 {
     if ($object == null) {
         $object = Objects::objects($model);
     }
     $reflex = new ReflectionClass($model->get_called_class());
     $properts = $reflex->getProperties();
     $fullname = $model->get_fullname();
     foreach ($properts as $propert) {
         $name = $propert->getName();
         $value = $model->{"get" . $name}();
         if ($value instanceof Constrain && $value->getType() == Constrain::FORAIN_KEY) {
             $refer_package = $value->getReferPackage();
             $refer_model = $value->getReferModel();
             Kernel::import($refer_package . "." . ucfirst($refer_model));
             $fullrefer = $value->getFullRefer();
             $refer_object = new $refer_model();
             $pk = $refer_object->get_pk();
             $pk_name = $pk->name();
             $class = strtolower($refer_object->get_called_class());
             if ($class == "user") {
                 $fullclass = $class;
                 $fullon = "{$fullname}.{$name} = {$class}.{$pk_name}";
             } else {
                 $fullclass = $refer_package . '_' . $class;
                 $fullon = "{$fullname}.{$name} = {$fullrefer}.{$pk_name}";
             }
             $object->join($fullclass, "{$fullon}");
             if ($prefix != null) {
                 $object->refer($fullclass, "{$fullon}");
             } else {
                 $object->refers[0] = $fullclass;
                 array_push($object->basest, "{$name} = {$name}" . "__" . "pk");
             }
             $object = self::by_model($refer_object, $object, ($prefix != null ? $prefix . "__" : "") . $name);
         }
         if ($value instanceof Constrain || $value instanceof Input) {
             if ($value instanceof Constrain && $value->getType() == Constrain::PRIMARY_KEY) {
                 $col = "pk";
             } else {
                 $col = $name;
             }
             $object->select($fullname . "." . $name . " AS " . ($prefix != null ? $prefix . "__" : "") . $col);
             if ($prefix != null) {
                 //var_dump($prefix . "---" . $name . "<br>");
                 $object->others($fullname . "." . $name . " AS " . ($prefix != null ? $prefix . "__" : "") . $col);
             }
         }
     }
     return $object;
 }
开发者ID:exildev,项目名称:q-stad,代码行数:57,代码来源:Objects.php


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