选择语言 :

 Module_OOP_ORM_Data::orm

获取当前ORM

OOP_ORM_Finder_DB Module_OOP_ORM_Data::orm( )
返回值
  • OOP_ORM_Finder_DB
  • OOP_ORM_Finder_Cache
  • OOP_ORM_Finder_HttpClient
File: ./modules/oop/orm/data.class.php
public function orm()
{
    if ( ! $this->_orm_object )
    {
        if ( ! $this->_orm_name )
        {
            $tmpobj = $this;
            while ( $tmpobj )
            {
                if ( is_object($tmpobj) )
                {
                    $classname = get_class($tmpobj);
                }
                else
                {
                    $classname = $tmpobj;
                }
                if ( preg_match('#^ORM_([a-z0-9_]+)_Data$#i', $classname, $m) )
                {
                    $this->_orm_name = $m[1];
                    break;
                }
                else
                {
                    $tmpobj = get_parent_class($tmpobj);
                }
            }
            unset($tmpobj);
        }
        if ( ! $this->_orm_name )
        {
            throw new Exception('$this->_orm_name未定义');
        }
        $orm_class_name = 'ORM_' . $this->_orm_name . '_Finder';

        if ( ! class_exists($orm_class_name, true) )
        {
            throw new Exception('指定的ORM对象“' . $orm_class_name . '”不存在');
        }
        $this->_orm_object = new $orm_class_name();
    }
    return $this->_orm_object;
}