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


PHP Jelly::class_name方法代码示例

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


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

示例1: __construct

 /**
  * Tracks a database result
  *
  * @param  mixed  $model
  * @param  mixed  $result
  */
 public function __construct($model, $result)
 {
     if ($model) {
         // Convert to a model
         $model = Jelly::class_name($model);
         // Instantiate the model, which we'll continually
         // fill with values when iterating
         $this->_model = new $model();
     }
     $this->_result = $result;
 }
开发者ID:jerfowler,项目名称:kohana-jelly,代码行数:17,代码来源:core.php

示例2: _where

 /**
  * Generates a builder where clause based on the provided values
  *
  * @param   Jelly_Builder   $builder
  * @param   string  $model  Model name used in the where clause
  * @param   mixed   $values argument list used to construct the clause
  * @return  Jelly_Builder
  */
 protected function _where($builder, $model, array $values)
 {
     // Check for an outer and/or indexed array
     $where = 'where';
     if (isset($values['or'])) {
         $where = 'or_where';
         $values = is_array($values['or']) ? $values['or'] : array($values['or']);
     } elseif (isset($values['and'])) {
         $where = 'and_where';
         $values = is_array($values['and']) ? $values['and'] : array($values['and']);
     }
     $count = count($values);
     /* One Argument is passed, can be:
      *  interger - for the primary key lookup
      *  string   - for the name key lookup
      *  object   - a loaded model of the same class
      */
     if ($count == 1) {
         if (is_integer($values[0])) {
             return $builder->{$where}($model . '.:primary_key', '=', $values[0]);
         } elseif (is_string($values[0])) {
             return $builder->{$where}($model . '.:name_key', '=', $values[0]);
         } elseif (is_object($values[0])) {
             $class = Jelly::class_name($model);
             if ($values[0] instanceof $class) {
                 return $builder->where($model . '.:primary_key', '=', $values[0]->id());
             }
         }
     } elseif ($count == 2) {
         if (!Jelly::meta($model)->fields($values[0])) {
             throw new Kohana_Exception('":field" is not a valid :model field', array(':field' => $values[0], ':model' => $model));
         }
         return $builder->{$where}($model . '.' . $values[0], '=', $values[1]);
     } elseif ($count == 3) {
         if (!Jelly::meta($model)->fields($values[0])) {
             throw new Kohana_Exception('":field" is not a valid :model field', array(':field' => $values[0], ':model' => $model));
         }
         return $builder->{$where}($model . '.' . $values[0], $values[1], $values[2]);
     }
     // Not Supported
     throw new Kohana_Exception('invalid or unsupported argument');
 }
开发者ID:jerfowler,项目名称:kohana-jelly,代码行数:50,代码来源:core.php

示例3: testClassNameConversion

 /**
  * @dataProvider providerClassNameConversion
  */
 public function testClassNameConversion($input, $expected)
 {
     $this->assertEquals($expected, Jelly::class_name($input));
 }
开发者ID:jonathangeiger,项目名称:jelly-tests,代码行数:7,代码来源:MetaData.php

示例4: test_class_name

 /**
  * Tests Jelly::class_name()
  * 
  * @dataProvider provider_class_name
  */
 public function test_class_name($model, $expected)
 {
     $this->assertSame($expected, Jelly::class_name($model));
 }
开发者ID:piotrtheis,项目名称:jelly,代码行数:9,代码来源:CoreTest.php

示例5: register

 /**
  * Automatically loads a model, if it exists,
  * into the meta table.
  *
  * Models are not required to register
  * themselves; it happens automatically.
  *
  * @param   string  $model
  * @return  boolean
  */
 public static function register($model)
 {
     $class = Jelly::class_name($model);
     $model = Jelly::model_name($model);
     // Don't re-initialize!
     if (isset(Jelly::$_models[$model])) {
         return TRUE;
     }
     // Can we find the class?
     if (class_exists($class)) {
         // Prevent accidentally trying to load ORM or Sprig models
         if (!is_subclass_of($class, "Jelly_Model")) {
             return FALSE;
         }
     } else {
         return FALSE;
     }
     // Load it into the registry
     Jelly::$_models[$model] = $meta = new Jelly_Meta($model);
     // Let the intialize() method override defaults.
     call_user_func(array($class, 'initialize'), $meta);
     // Finalize the changes
     $meta->finalize($model);
     return TRUE;
 }
开发者ID:joelpittet,项目名称:kohana-jelly,代码行数:35,代码来源:core.php

示例6: as_object

 /**
  * Returns results as objects
  *
  * @param   string|bool  $class TRUE for StdClass
  * @param   array|null   $params
  * @return  Kohana_Database_Query
  */
 public function as_object($class = TRUE, array $params = NULL)
 {
     // Class is TRUE, default to the model
     if ($class === TRUE and $this->_meta) {
         $class = Jelly::class_name($this->_meta->model());
     }
     return parent::as_object($class);
 }
开发者ID:piotrtheis,项目名称:jelly,代码行数:15,代码来源:builder.php

示例7: field

 /**
  * Getter / setter for individual fields.
  *
  * @param   string       $name     name of the field
  * @param   mixed        $field    the field alias or object
  * @return  Jelly_Field|Jelly_Meta|null
  */
 public function field($name, $field = NULL)
 {
     if ($field === NULL) {
         // Get the field
         if (!isset($this->_field_cache[$name])) {
             // Set the resolved name to the given name for now
             $resolved_name = $name;
             if (isset($this->_aliases[$name])) {
                 // If the field is among the aliases set the alias as resolved name
                 $resolved_name = $this->_aliases[$name];
             }
             if (isset($this->_fields[$resolved_name])) {
                 // Get the field from cache using the resolved name
                 $this->_field_cache[$name] = $this->_fields[$resolved_name];
             } else {
                 // No such field found
                 return NULL;
             }
         }
         // Return the field
         return $this->_field_cache[$name];
     }
     if ($this->_initialized) {
         // Cannot set after initialization
         throw new Kohana_Exception(':class already initialized, cannot set :field', array(':class' => Jelly::class_name($this->_model), ':field' => $name));
     }
     // Set the field
     $this->_fields[$name] = $field;
     // Return Jelly_Meta
     return $this;
 }
开发者ID:piotrtheis,项目名称:jelly,代码行数:38,代码来源:meta.php


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