/** * Constructor opens a connection to the database * @param string $module Module text for End-to-End Application Tracing * @param string $cid Client Identifier for End-to-End Application Tracing */ function __construct($module, $cid) { $this->conn = @oci_pconnect(SCHEMA, PASSWORD, DATABASE, CHARSET); if (!$this->conn) { $m = oci_error(); throw new \Exception('No se puede conectar a la base de datos: ' . $m['message']); } // Record the "name" of the web user, the client info and the module. // These are used for end-to-end tracing in the DB. oci_set_client_info($this->conn, CLIENT_INFO); oci_set_module_name($this->conn, $module); oci_set_client_identifier($this->conn, $cid); }
/** * Constructor opens a connection to the database * @param string $module Module text for End-to-End Application Tracing * @param string $cid Client Identifier for End-to-End Application Tracing * @throws \Exception */ public function __construct($module, $cid) { $this->conn = @oci_new_connect(O_USERNAME, O_PASSWORD, O_DATABASE, O_CHARSET); if (!$this->conn) { $m = oci_error(); throw new \Exception("Cannot open connection to Oracle db " . $m["message"]); } // Record the "name" of the web user, the client info and the module. // These are used for end-to-end tracing in the DB. oci_set_client_info($this->conn, CLIENT_INFO); oci_set_module_name($this->conn, $module); oci_set_client_identifier($this->conn, $cid); }
/** * This method makes sure to connect to the database properly * * @param string $strHost * @param string $strUsername * @param string $strPass * @param string $strDbName * @param int $intPort * * @return bool * @throws class_exception */ public function dbconnect($strHost, $strUsername, $strPass, $strDbName, $intPort) { if ($intPort == "") { $intPort = "1521"; } //save connection-details $this->strHost = $strHost; $this->strUsername = $strUsername; $this->strPass = $strPass; $this->strDbName = $strDbName; $this->intPort = $intPort; //try to set the NLS_LANG env attribute putenv("NLS_LANG=American_America.UTF8"); $this->linkDB = @oci_connect($strUsername, $strPass, $strHost . ":" . $intPort . "/" . $strDbName, "AL32UTF8"); if ($this->linkDB !== false) { @oci_set_client_info($this->linkDB, "Kajona CMS"); return true; } else { throw new class_exception("Error connecting to database", class_exception::$level_FATALERROR); } }
public function SetClientInfo(string $client_info) { return @oci_set_client_info($this->conn_handle, $client_info); }
/** * Utiliza o recurso do Oracle que permite vincular informações do usuário da aplicação à sua sessão no banco de dados. * @param type $userId * @param type $userIP * @param type $module * @param type $action */ public function setUserInformation($userId, $userIP = null, $module = null, $action = null) { oci_set_client_identifier($this->dbh, $userId); if ($userIP) { oci_set_client_info($this->dbh, $userIP); } if ($module) { oci_set_module_name($this->dbh, $module); } if ($action) { oci_set_action($this->dbh, $action); } }
public function setClientInfo($clientInfo) { set_error_handler(static::getErrorHandler()); $isSuccess = oci_set_client_info($this->resource, $clientInfo); restore_error_handler(); return $isSuccess; }