Model::_get_table_name PHP Метод

_get_table_name() защищенный статический Метод

If the supplied class has a public static property named $_table, the value of this property will be returned. If not, the class name will be converted using the _class_name_to_table_name method method. If Model::$short_table_names == true or public static property $_table_use_short_name == true then $class_name passed to _class_name_to_table_name is stripped of namespace information.
protected static _get_table_name ( string $class_name ) : string
$class_name string
Результат string
    protected static function _get_table_name($class_name)
    {
        $specified_table_name = self::_get_static_property($class_name, '_table');
        $use_short_class_name = self::_use_short_table_name($class_name);
        if ($use_short_class_name) {
            $exploded_class_name = explode('\\', $class_name);
            $class_name = end($exploded_class_name);
        }
        if (is_null($specified_table_name)) {
            return self::_class_name_to_table_name($class_name);
        }
        return $specified_table_name;
    }

Usage Example

Пример #1
0
 /**
  * Returns an ORM instance for the table attached to the model. Because
  * of the need for late static binding this only works for PHP >= 5.3. 
  * For PHP < 5.3 the following must be placed in each of the subclassing 
  * models:
  * 
  *     public static function objects() { 
  *         return parent::objects(__CLASS__); 
  *     }
  * 
  * @param type $class_name
  * @return type ORM
  */
 public static function objects($class_name = null)
 {
     $has_late_static_binding = function_exists('get_called_class');
     if (!$has_late_static_binding && is_null($class_name)) {
         throw Exception('PHP versions < 5.3 must override the objects' . 'method.');
     }
     if ($has_late_static_binding && is_null($class_name)) {
         $class_name = get_called_class();
     }
     $table_name = Model::_get_table_name($class_name);
     return ORM::for_table($table_name);
 }