Location: PHPKode > projects > litephp > litephp-master/m.class.php
<?php
class M{
	private static $pro=array();
	public $primary_key='id';//default primary key : id
	
	function __get($name)
	{
		if($name==='db')
		{
			require_once(CORE_PATH.'lib/db.class.php');
			$mod_name=get_class($this);
			$table=substr($mod_name,1);//get table name
			if(!isset(self::$pro[$table]))//one table share one object
			{
				self::$pro[$table]=new db($table,$this->primary_key);
			}
			return self::$pro[$table];
		}
		fatal_error('unknow lib:'.$name);
	}
}
Return current item: litephp