/**
  * @desc Load model by name, if not found, null will be returned
  * @param string $model_name
  * @return sql_model
  */
 public function get_model($model_name)
 {
     $pkgman = pkgman_manager::get_instance();
     $models = $this->link->config['models'];
     if (is_string($models)) {
         $class_name = "{$models}_{$model_name}";
         if (!$pkgman->load_class($class_name)) {
             return null;
         }
         return new $class_name($this->link, $model_name);
     } else {
         foreach ($models as $pkg) {
             $class_name = "{$models}_{$model_name}";
             if (!$pkgman->load_class($class_name)) {
                 continue;
             }
             return new $class_name($this->link, $model_name);
         }
         return null;
     }
 }
Beispiel #2
0
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Note: this GNU GPL license disclaimer applies to all files contained
  in this directory and all it's subdirectories
*/
// Main initialization script that is used to initialize the package system
if (version_compare("5.1.0", PHP_VERSION, ">")) {
    die("pkgmanager requires PHP5 or later!");
}
define("_PKGMAN_ROOT", rtrim(dirname(__FILE__), "\\/"));
// if true, will use spl_autoload_register(), else will define __autoload functions
if (!defined('_PKGMAN_USE_SPL_AUTOLOAD')) {
    define("_PKGMAN_USE_SPL_AUTOLOAD", true);
}
require _PKGMAN_ROOT . "/pkgman_manager.class.php";
require _PKGMAN_ROOT . "/pkgman_package.class.php";
/* @var pkgman_manager */
$_pkgman = pkgman_manager::get_instance();
if (_PKGMAN_USE_SPL_AUTOLOAD) {
    function _pkgman_autoload($class)
    {
        pkgman_manager::$instance->load_class($class);
    }
    spl_autoload_register('_pkgman_autoload');
} else {
    // if not using spl_autoload
    function __autoload($class)
    {
        pkgman_manager::$instance->load_class($class);
    }
}