function &m($model_name, $ params
= array(), $is_new = false )
{
<span style= "background-color: rgb(255, 0, 0);" > static
$models = array();</span>
$model_hash = md5($model_name . var_export($ params , true ));
if
($is_new || !isset($models[$model_hash]))
{
$model_file = ROOT_PATH . ‘/includes/models/‘
. $model_name . ‘.model.php‘ ;
if
(!is_file($model_file))
{
/* 不存在该文件,则无法获取模型 */
return
false ;
}
include_once($model_file);
$model_name = ucfirst($model_name) . ‘Model‘ ;
if
($is_new)
{
return
new $model_name($ params , db());
}
$models[$model_hash] = new
$model_name($ params , db());
}
print_r($models[$model_hash]);
return
$models[$model_hash];
}
/**
* 获取一个业务模型
*
* @param string $model_name
* @param array $params
* @param bool $is_new
* @return object
*/
function &bm($model_name, $ params
= array(), $is_new = false )
{
<span style= "background-color: rgb(255, 0, 0);" > static
$models = array();</span>
$model_hash = md5($model_name . var_export($ params , true ));
if
($is_new || !isset($models[$model_hash]))
{
$model_file = ROOT_PATH . ‘/includes/models/‘
. $model_name . ‘.model.php‘ ;
if
(!is_file($model_file))
{
/* 不存在该文件,则无法获取模型 */
return
false ;
}
include_once($model_file);
$model_name = ucfirst($model_name) . ‘BModel‘ ;
if
($is_new)
{
return
new $model_name($ params , db());
}
$models[$model_hash] = new
$model_name($ params , db());
}
return
$models[$model_hash];
}
|