public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new ORMConfig();
     }
     return self::$instance;
 }
	public static function getInstance(){
		if(self::$instance === null){
			$adapter = ORMConfig::get('adapter','orm').'Adapter';
			self::$instance = new $adapter();
		}
		
		return self::$instance;
	}
 public function __construct()
 {
     $host = ORMConfig::get('host', 'mongodb') ? ORMConfig::get('host', 'mongodb') : 'localhost';
     $port = ORMConfig::get('port', 'mongodb') ? ORMConfig::get('port', 'mongodb') : '27017';
     $this->service = new Mongo("mongodb://{$host}:{$port}", array('connect' => true));
     $this->service = $this->service->selectDB(ORMConfig::get('database', 'mongodb'));
     if (ORMConfig::get('username', 'mongodb') && ORMConfig::get('password', 'mongodb')) {
         $this->service->authenticate(ORMConfig::get('username', 'mongodb'), ORMConfig::get('password', 'mongodb'));
     }
 }
 private function dateTime()
 {
     $sDefaultFormat = ORMConfig::get('date_format', 'orm');
     if (!is_null($this->format)) {
         $sFormat = $this->format;
     } elseif (!empty($sDefaultFormat)) {
         $sFormat = $sDefaultFormat;
     } else {
         $sFormat = DateTime::RSS;
     }
     $datetime = new Datetime($this->input);
     return $datetime->format($sFormat);
 }
 public function buildQuery($bLimit = false)
 {
     $sSql = "db." . ORMConfig::get('database', 'mongodb');
     #$sSql .= $this->sSelect;
     $sSql .= "." . $this->sFrom . '.';
     foreach ($this->aWhere as $a) {
         $this->parseValue($a);
     }
     if (!is_null($this->sOrderBy)) {
         #$sSql .= " ORDER BY ".$this->sOrderBy;
         if (!is_null($this->sLimit) or $bLimit) {
             #$sSql .= " LIMIT ";
             #$sSql .= ( $bLimit ) ? 1 : $this->sLimit;
             return $this->aExist;
         }
     }
 }
 public function __call($name, $arguments)
 {
     $value = $this->formatLabel(substr($name, 3, strlen($name)));
     $name = strtolower(substr($name, 0, 3));
     if (ORMConfig::get('strict', 'orm')) {
         if (!is_array(Schema::get(ORMConfig::get('schema', 'orm'), $this->sDomain, $value))) {
             throw new Exception($value . ' was not found in schema');
         }
     }
     if ($name == 'set') {
         return $this->set($value, $arguments);
     } elseif ($name == 'get') {
         return $this->get($value, $arguments);
     } elseif ($name == 'add') {
         return $this->add($value, $arguments);
     } else {
         throw new Exception('Method does not exist');
     }
 }
 public function __construct()
 {
     $this->service = new Amazon_SimpleDB_Client(ORMConfig::get('access_key', 'amazon'), ORMConfig::get('secret_key', 'amazon'), array('Timeout' => ORMConfig::get('timeout', 'amazon')));
 }