当前位置: 首页>>代码示例>>PHP>>正文


PHP oci_connect函数代码示例

本文整理汇总了PHP中oci_connect函数的典型用法代码示例。如果您正苦于以下问题:PHP oci_connect函数的具体用法?PHP oci_connect怎么用?PHP oci_connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了oci_connect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: readCursor

 public function readCursor($storedProcedure, $binds)
 {
     //
     // This function needs two parameters:
     //
     // $storedProcedure - the name of the stored procedure to call a chamar. Ex:
     //  my_schema.my_package.my_proc(:param)
     //
     // $binds - receives an array of associative arrays with: parameter names,
     // values and sizes
     //
     // WARNING: The first parameter must be consistent with the second one
     $conn = oci_connect('SECMAN', 'SECMAN', '(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.10.24)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = cisqa)))');
     if ($conn) {
         // Create the statement and bind the variables (parameter, value, size)
         $stid = oci_parse($conn, 'begin :cursor := ' . $storedProcedure . '; end;');
         foreach ($binds as $variable) {
             oci_bind_by_name($stid, $variable["parameter"], $variable["value"], $variable["size"]);
         }
         // Create the cursor and bind it
         $p_cursor = oci_new_cursor($conn);
         oci_bind_by_name($stid, ':cursor', $p_cursor, -1, OCI_B_CURSOR);
         // Execute the Statement and fetch the data
         oci_execute($stid);
         oci_execute($p_cursor, OCI_DEFAULT);
         oci_fetch_all($p_cursor, $data, null, null, OCI_FETCHSTATEMENT_BY_ROW);
         // Return the data
         return $data;
     }
 }
开发者ID:fajarnugrohoid,项目名称:nontaglis,代码行数:30,代码来源:OracleModel.php

示例2: conn_db

 public static function conn_db($dbdata)
 {
     if (is_array($dbdata)) {
         extract($dbdata[Db::$dbconn]);
         Db::$db = @$dbtype;
     }
     $error = '';
     switch (Db::$db) {
         case 'Pg':
             $con = pg_connect("host={$host} port={$port} dbname={$database} user={$user} password={$password}") or die("{$error}=" . pg_result_error());
             break;
         case 'Mysql':
             $con = mysql_connect($host . ':' . $port, $user, $password);
             mysql_select_db($database) or die("{$error}=" . mysql_error());
             break;
         case 'Oci':
             $con = oci_connect($user, $password, $host . ':' . $port . '/' . $database);
             if (!$con) {
                 $error = oci_error();
                 trigger_error(htmlentities($error['message'], ENT_QUOTES), E_USER_ERROR);
             }
             break;
     }
     if ($error != '') {
         $con = $error;
     }
     return $con;
 }
开发者ID:hezrul,项目名称:seashell,代码行数:28,代码来源:class.db.php

示例3: get_filteredGames

function get_filteredGames($data)
{
    // The connection string is loooooooong. It's easiest to copy/paste this line. Remember to replace 'username' and 'password'!
    $conn = oci_connect('malz', '1Qaz2wsx', '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(Host=db1.chpc.ndsu.nodak.edu)(Port=1521)))(CONNECT_DATA=(SID=cs)))');
    if ($data === 'all') {
        $results = array();
        $query = 'select * from Game';
        $stid = oci_parse($conn, $query);
        oci_bind_by_name($stid, ':data', $data);
        oci_execute($stid);
        //iterate through each row
        while ($row = oci_fetch_array($stid, OCI_ASSOC)) {
            $results[] = $row;
        }
        echo json_encode($results);
        oci_free_statement($stid);
        oci_close($conn);
    } else {
        $results = array();
        $data = $data . '%';
        $query = 'select * from Game where gameName like :data';
        $stid = oci_parse($conn, $query);
        oci_bind_by_name($stid, ':data', $data);
        oci_execute($stid);
        //iterate through each row
        while ($row = oci_fetch_array($stid, OCI_ASSOC)) {
            $results[] = $row;
        }
        echo json_encode($results);
        oci_free_statement($stid);
        oci_close($conn);
    }
}
开发者ID:GabieJay,项目名称:CatBoard,代码行数:33,代码来源:Search.php

示例4: connection

 public function connection($user, $password, $database)
 {
     $this->conn = oci_connect($user, $password, $database);
     if (!$this->conn) {
         throw new Exception("Falla en la coneccion a la base de datos [" . $this->name . "]", 1);
     }
 }
开发者ID:aldomendez,项目名称:loquacious-octo-rutabaga,代码行数:7,代码来源:database.php

示例5: connectionobject

 public static function connectionobject($host, $db, $user, $password)
 {
     if (self::$usepdo) {
         /*$db = "  
         		(DESCRIPTION =
         			(ADDRESS_LIST =
         			  (ADDRESS = (PROTOCOL = TCP)(HOST = yourip)(PORT = 1521))
         			)
         			(CONNECT_DATA =
         			  (SERVICE_NAME = orcl)
         			)
         		  )
         			   ";*/
         return new \PDO("oci:dbname=" . $db, $user, $password);
     } else {
         /*$db = "  
         		(DESCRIPTION =
         			(ADDRESS_LIST =
         			  (ADDRESS = (PROTOCOL = TCP)(HOST = yourip)(PORT = 1521))
         			)
         			(CONNECT_DATA =
         			  (SERVICE_NAME = orcl)
         			)
         		  )
         			   ";*/
         $ob = oci_connect($user, $password, $db);
         self::$ob[self::$database_in_use] = $ob;
         if (!$ob) {
             self::oci8_debug($ob, $str_sql);
         }
         return $ob;
     }
 }
开发者ID:charlesjohannisen,项目名称:nise.php,代码行数:33,代码来源:ORACLE.php

示例6: testConnection

 public function testConnection($db_info)
 {
     if (!$this->isValid($db_info)) {
         return false;
     }
     foreach ($db_info as $key => $value) {
         if (empty($db_info[$key])) {
             unset($db_info[$key]);
         }
     }
     if ($db_info['db_oracle_type'] == 'tns') {
         $connect = @oci_connect($db_info['db_user'], $db_info['db_password'], $db_info['db_net_service_name']);
         if (!$connect) {
             $error = oci_error();
             throw new \Exception($error['message'], $error['code']);
         }
     } else {
         $dsn = $db_info['db_host'];
         $dsn .= ':' . $db_info['db_port'];
         $dsn .= '/' . $db_info['db_service_name'];
         $connect = @oci_connect($db_info['db_user'], $db_info['db_password'], $dsn);
         if (!$connect) {
             $error = oci_error();
             throw new \Exception($error['message'], $error['code']);
         }
     }
     return true;
 }
开发者ID:reliv,项目名称:rcm-install,代码行数:28,代码来源:Oci.php

示例7: _connect

 /**
  * Creates a connection resource.
  *
  * @return void
  * @throws Zend_Db_Adapter_Oracle_Exception
  */
 protected function _connect()
 {
     if (is_resource($this->_connection)) {
         // connection already exists
         return;
     }
     if (!extension_loaded('oci8')) {
         /**
          * @see Zend_Db_Adapter_Oracle_Exception
          */
         require_once 'Zend/Db/Adapter/Oracle/Exception.php';
         throw new Zend_DB_Adapter_Oracle_Exception('The OCI8 extension is required for this adapter but not loaded');
     }
     if (isset($this->_config['dbname'])) {
         $this->_connection = @oci_connect($this->_config['username'], $this->_config['password'], $this->_config['dbname']);
     } else {
         $this->_connection = oci_connect($this->_config['username'], $this->_config['password']);
     }
     // check the connection
     if (!$this->_connection) {
         /**
          * @see Zend_Db_Adapter_Oracle_Exception
          */
         require_once 'Zend/Db/Adapter/Oracle/Exception.php';
         throw new Zend_Db_Adapter_Oracle_Exception(oci_error());
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:33,代码来源:Oracle.php

示例8: connect

 /**
  * Make connection
  *
  * @return object value
  */
 public function connect()
 {
     if (self::$connection === NULL) {
         self::$connection = oci_connect(_dbUser, _dbPwd, _dbHost . ":" . _dbPort . "/" . _dbName);
     }
     return self::$connection;
 }
开发者ID:no2key,项目名称:ZanPHP,代码行数:12,代码来源:oracle.php

示例9: purchaseTicket

 function purchaseTicket()
 {
     $passenger = unserialize($_SESSION['passengerDetails']);
     $flightDetails = unserialize($_SESSION['flightDetailsForBooking']);
     $flightDetails->setFare($_SESSION['lastPurchased']);
     $userId = $_SESSION['userId'];
     $modeOfPayment = $_SESSION['modeOfPayment'];
     ini_set('display_errors', 'On');
     $db = "w4111c.cs.columbia.edu:1521/adb";
     $conn = oci_connect("kpg2108", "test123", $db);
     $ticketid = rand();
     $stmt = "insert into ticket values('" . $ticketid . "','" . rand() . "','" . $flightDetails->getFlightClassId() . "','" . $userId . "','" . date('m/d/Y') . "','" . $flightDetails->getFlightMiles() . "')";
     $stmt1 = oci_parse($conn, $stmt);
     $result2 = oci_execute($stmt1);
     $stmt2 = "insert into passenger values('" . rand() . "','" . $ticketid . "','" . $passenger->getfname() . "','" . $passenger->getlname() . "','" . $passenger->getage() . "')";
     $stmt3 = oci_parse($conn, $stmt2);
     $result3 = oci_execute($stmt3);
     $stmt4 = "insert into payment values('" . rand() . "','" . $ticketid . "','" . $modeOfPayment . "','" . $flightDetails->getfare() . "','" . date('m/d/Y') . "')";
     $stmt5 = oci_parse($conn, $stmt4);
     $result2 = oci_execute($stmt5);
     $stmtUpdate = "update users set Miles='" . $_SESSION['userMiles'] . "' where user_id='" . $_SESSION['userId'] . "'";
     $stmtUpdate1 = oci_parse($conn, $stmtUpdate);
     $result3 = oci_execute($stmtUpdate1);
     $stmt9 = "update flight_class set no_of_seats ='" . ($flightDetails->getSeatsAvailable() - 1) . "' where flight_class_id='" . $flightDetails->getFlightClassId() . "'";
     $stmtUpdate2 = oci_parse($conn, $stmt9);
     $result4 = oci_execute($stmtUpdate2);
     oci_close($conn);
     if ($result2) {
         return 1;
     }
 }
开发者ID:NLP-Project,项目名称:AirLine-Reservation-System,代码行数:31,代码来源:BookingModel.php

示例10: connect

 /**
  * Connect to a database
  * @throws Doctrine_Adapter_Exception
  * @return void
  */
 private function connect()
 {
     $this->connection = @oci_connect($this->config['username'], $this->config['password'], $this->config['dbname'], $this->config['charset']);
     if ($this->connection === false) {
         throw new Doctrine_Adapter_Exception(sprintf("Unable to Connect to :'%s' as '%s'", $this->config['dbname'], $this->config['username']));
     }
 }
开发者ID:googlecode-mirror,项目名称:orso,代码行数:12,代码来源:Oracle.php

示例11: connect

 function connect()
 {
     if (0 == $this->Link_ID) {
         if ($this->Debug) {
             printf("<br>Connecting to {$this->Database}%s...<br>\n", $this->Host ? " ({$this->Host})" : "");
         }
         if ($this->share_connections) {
             if (!$this->share_connection_name) {
                 $this->share_connection_name = get_class($this) . "_Link_ID";
             } else {
                 $this->share_connection_name .= "_Link_ID";
             }
             global ${$this->share_connection_name};
             if (${$this->share_connection_name}) {
                 $this->Link_ID = ${$this->share_connection_name};
                 return true;
             }
         }
         if ($this->persistent) {
             $this->Link_ID = oci_pconnect($this->User, $this->Password, $this->Host ? sprintf($this->full_connection_string, $this->Host, $this->Port, $this->Database) : $this->Database, 'AL32UTF8');
         } else {
             $this->Link_ID = oci_connect($this->User, $this->Password, $this->Host ? sprintf($this->full_connection_string, $this->Host, $this->Port, $this->Database) : $this->Database, 'AL32UTF8');
         }
         if (!$this->Link_ID) {
             $this->connect_failed();
             return false;
         }
         if ($this->share_connections) {
             ${$this->share_connection_name} = $this->Link_ID;
         }
         if ($this->Debug) {
             printf("<br>Obtained the Link_ID: {$this->Link_ID}<br>\n");
         }
     }
 }
开发者ID:HaakonME,项目名称:porticoestate,代码行数:35,代码来源:class.db_oci8.inc.php

示例12: connect

 public function connect()
 {
     if (is_null(self::$connection)) {
         self::$connection = oci_connect(DB_HOST, DB_USER, DB_PWD . ":" . DB_PORT . "/" . DB_DATABASE);
     }
     return self::$connection;
 }
开发者ID:jgianpiere,项目名称:ZanPHP,代码行数:7,代码来源:oracle.php

示例13: Connect

 /**
  * Připojí k vybrané databázi dle konstruktoru.
  */
 function Connect()
 {
     // připojení k DB provedu dle požadovaného typu
     if ($this->connection_type == DB_CONNECTION_USE_PDO_MYSQL) {
         // PDO - MySQL
         try {
             $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
             $this->connection = new PDO("mysql:host=" . MYSQL_DATABASE_SERVER . ";dbname=" . MYSQL_DATABASE_NAME . "", MYSQL_DATABASE_USER, MYSQL_DATABASE_PASSWORD, $options);
             // nastavit pripojeni na UTF-8 - pro starsi verze PHP
             //$this->connection->exec("SET NAMES UTF8");
         } catch (PDOException $e) {
             print "Error!: " . $e->getMessage() . "<br/>";
             die;
         }
     } else {
         // DIRECT Oracle
         // $kodovani - 'EE8MSWIN1250' = Windows 1250
         //$kodovani = 'EE8MSWIN1250'; // CP-1250
         $kodovani = 'AL32UTF8';
         // UTF-8
         $this->connection = oci_connect(ORACLE_DATABASE_USER, ORACLE_DATABASE_PASSWORD, ORACLE_DATABASE_NAME, $kodovani);
         // pomocna chyba
         $chyba = oci_error();
         if ($chyba != null) {
             echo "Chyba při připojení k DB: ";
             printr($chyba);
         }
     }
 }
开发者ID:Goheeca,项目名称:kiv-web,代码行数:32,代码来源:predmety.class.php

示例14: __construct

 /**
  * Class constructor
  *
  * @param string $data     the connection string
  * @param string $username user name
  * @param string $password password
  * @param string $options  options to send to the connection
  *
  * @return \PDO object
  * @throws \PDOException
  */
 public function __construct($data, $username, $password, $options = null)
 {
     if (!function_exists("\\oci_parse")) {
         throw new \PDOException("No support for Oracle, please install the OCI driver");
     }
     // find charset
     $charset = null;
     $data = preg_replace('/^oci:/', '', $data);
     $tokens = preg_split('/;/', $data);
     $data = str_replace(array('dbname=//', 'dbname='), '', $tokens[0]);
     $charset = $this->_getCharset($tokens);
     try {
         if (!is_null($options) && array_key_exists(\PDO::ATTR_PERSISTENT, $options)) {
             $this->_con = \oci_pconnect($username, $password, $data, $charset);
             $this->setError();
         } else {
             $this->_con = \oci_connect($username, $password, $data, $charset);
             $this->setError();
         }
         if (!$this->_con) {
             $error = oci_error();
             throw new \Exception($error['code'] . ': ' . $error['message']);
         }
     } catch (\Exception $exception) {
         throw new \PDOException($exception->getMessage());
     }
     return $this;
 }
开发者ID:taq,项目名称:pdooci,代码行数:39,代码来源:PDO.php

示例15: __construct

 /**
  * Constructor
  *
  * @param string $dsn
  * @param string $username
  * @param string $passwd
  * @param array $options
  * @return void
  */
 public function __construct($dsn, $username = null, $password = null, array $options = array())
 {
     //Parse the DSN
     $parsedDsn = self::parseDsn($dsn, array('charset'));
     //Get SID name
     $sidString = isset($parsedDsn['sid']) ? '(SID = ' . $parsedDsn['sid'] . ')' : '';
     //Create a description to locate the database to connect to
     $description = '(DESCRIPTION =
         (ADDRESS_LIST =
             (ADDRESS = (PROTOCOL = TCP)(HOST = ' . $parsedDsn['hostname'] . ')
             (PORT = ' . $parsedDsn['port'] . '))
         )
         (CONNECT_DATA =
                 ' . $sidString . '
                 (SERVICE_NAME = ' . $parsedDsn['dbname'] . ')
         )
     )';
     //Attempt a connection
     if (isset($options[\PDO::ATTR_PERSISTENT]) && $options[\PDO::ATTR_PERSISTENT]) {
         $this->_dbh = @oci_pconnect($username, $password, $description, $parsedDsn['charset']);
     } else {
         $this->_dbh = @oci_connect($username, $password, $description, $parsedDsn['charset']);
     }
     //Check if connection was successful
     if (!$this->_dbh) {
         $e = oci_error();
         throw new \PDOException($e['message']);
     }
     //Save the options
     $this->_options = $options;
 }
开发者ID:crazycodr,项目名称:pdo-via-oci8,代码行数:40,代码来源:Oci8.php


注:本文中的oci_connect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。