Location: PHPKode > projects > Phpgrid > core/model.php
<?php
/**
 * model.php :: Power2php 的模型基类
 * 所有的模型类建议继承该类
 * Power2php version 1.5
 *
 * @package core
 * @author  diy,kate
 * @copyright Copyright (c) 2007-2008  by cd_wei
 * @license GNU General Public License (GPL),
 * @website http://phpgrid.sf.net,
 */

if ( ! defined('PROJECT_DIR')) exit('您必须在config中先定义常量PROJECT_DIR');

require_once (PROJECT_DIR.'/libs/mypdo.class.php');


/**
 * MVC框架中的model基类,所有的model可以继承于于该,该类现在只用于连接数据库
 * @author
 * @version      1.0
 * @date         2007 911
 */
class Model
{

	public  $db ;


	/**
	 * 构造函数,用于初始化数据库连接
	 */
	function Model(){
		/**
		$options=$GLOBALS['phpgrid']['db'];
		
		$dsn = $options['type'].":host=".$options['host'].";port=".$options['port'].";dbname=".$options['dbname'];
		try{
			$db = new mypdo($dsn,$options['user'],$options['passwd'],array(PDO::ATTR_PERSISTENT => false));
		}catch (PDOException $e){
			trigger_error("db connect failed!".$e->getMessage(),E_USER_ERROR);
			die();
		}
		$db->query("set names '".$options['charset']."'");
		$this->db=$db ;
		*/

	}

	//获得model 的db属性
	function getDB(){
		return $this->db;
	}


	//设置model 的db属性
	function  setDB($db){
		$this->db=$db;
	}






}



Return current item: Phpgrid