/** * @see Yun_Db_Mysql_Adapter_Interface::connect() */ public function connect(array $conf) { $socket = Yun_Array::get($conf, 'socket', ''); $host = Yun_Array::get($conf, 'host'); $port = Yun_Array::get($conf, 'port'); $dbname = Yun_Array::get($conf, 'dbname'); $user = Yun_Array::get($conf, 'user'); $pass = Yun_Array::get($conf, 'pass'); $this->mysqli = new mysqli($host, $user, $pass, $dbname, $port, $socket); if ($this->mysqli->connect_errno) { $this->error_code = $this->mysqli->connect_errno; $this->error_info = $this->mysqli->connect_error; return false; } else { return true; } }
/** * * @see Yun_Db__Adapter_Interface::connect() */ public function connect(array $conf) { try { $host = Yun_Array::get($conf, 'host'); $port = Yun_Array::get($conf, 'port'); $dbname = Yun_Array::get($conf, 'dbname'); $user = Yun_Array::get($conf, 'user'); $pass = Yun_Array::get($conf, 'pass'); $dsn = "pgsql:host={$host};port={$port};dbname={$dbname}"; $pdo = new Pdo($dsn, $user, $pass); $this->initPdo($pdo); return true; } catch (Exception $e) { $this->error_code = $e->getCode(); $this->error_info = $e->getMessage(); return false; } }
private function log($level, $msg, $handler_id) { $handler = Yun_Array::get($this->handler, $handler_id); if (!$handler instanceof Yun_Log_Handler_Interface) { return $this->error($msg, $error, self::DEFAULT_HANDLER_ID); } $loginfo = sprintf("%s %s {$level} %s\n", date('Ymd-H:i:s'), self::$request_id, $msg); $handler->log($loginfo); }