Esempio n. 1
0
    /**
     *@package db_firebird
     *@method connect()
     *@desc Open a connection to a Firebird/Interbase DB
     *@since v0.3.1
     * */
    public static function connect($p_host = NULL, $p_user = NULL, $p_pass = NULL, $p_db = NULL)
    {
        $H = isset($p_host) ? $p_host : self::$host;
        $U = isset($p_user) ? $p_user : self::$user;
        $P = isset($p_pass) ? $p_pass : self::$pass;
        $D = isset($p_db) ? $p_db : self::$database;
        $connection = @ibase_connect($H . ':' . $D, $U, $P);
        if ($connection == FALSE) {
            try {
                throw new FkException("Error al conectar a la db ");
            } catch (FkException $e) {
                $e->description = 'Firebird/Interbase Respondi&oacute;:' . ibase_errmsg() . '</b>';
                $e->solution = 'Verifique la conexion, posiblemente el archivo /app/config/environment.ini no contiene los datos de conexion correctos. Vea ejemplo:';
                $e->solution_code = fk_str_format('[development]
db_host = localhost
db_username = tester
db_password = test
db_name = freekore_dev
db_type = firebird', 'html');
                $e->error_code = 'DB000002';
                $e->show('code_help');
            }
        } else {
            self::$is_connected = true;
        }
    }
Esempio n. 2
0
 public function connect(array $params)
 {
     $host = $params["host"] . ":" . $params["database"];
     $enc = isset($params["charset"]) ? $params["charset"] : null;
     $conn = ibase_connect($host, $params["user"], $params["password"], $enc);
     return $conn ? $conn : ibase_errmsg();
 }
Esempio n. 3
0
 public function connect($hostname, $database, $username, $password, $port = 3050)
 {
     $this->connection = ibase_connect($hostname . "/" . $port . ":" . $database, $username, $password);
     if (!$this->connection) {
         throw new Exception(ibase_errmsg());
     }
 }
Esempio n. 4
0
 function Open()
 {
     $this->link_id = ibase_connect($this->Host, $this->UserName, $this->Password);
     if (!$this->link_id) {
         $this->ErrorCode = 1;
         $this->ErrorMsg = "Host를 연결할 수가 없습니다.";
     }
 }
Esempio n. 5
0
 public function connect($config = array())
 {
     $this->config = $config;
     $this->connect = $this->config['pconnect'] === true ? @ibase_pconnect($this->config['host'] . ':' . $this->config['database'], $this->config['user'], $this->config['password'], $this->config['charset']) : @ibase_connect($this->config['host'] . ':' . $this->config['database'], $this->config['user'], $this->config['password'], $this->config['charset']);
     if (empty($this->connect)) {
         die(getErrorMessage('Database', 'mysqlConnectError'));
     }
 }
Esempio n. 6
0
 /**
  * Connects to the database.
  *
  * This function connects to a ibase database
  *
  * @param   string $host
  * @param   string $username
  * @param   string $password
  * @param   string $db_name
  * @return  boolean true, if connected, otherwise false
  * @access  public
  * @author  Thorsten Rinne <*****@*****.**>
  * @since   2005-04-16
  */
 function connect($host, $user, $passwd, $db)
 {
     $this->conn = ibase_connect($db, $user, $passwd);
     if (false == $this->conn) {
         PMF_Db::errorPage(ibase_errmsg());
         die;
     }
     return true;
 }
Esempio n. 7
0
 function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
 {
     $this->persistency = $persistency;
     $this->user = $sqluser;
     $this->server = $sqlserver . ($port ? ':' . $port : '');
     $this->dbname = $database;
     $this->db_connect_id = $this->persistency ? @ibase_pconnect($this->server . ':' . $this->dbname, $this->user, $sqlpassword, false, false, 3) : @ibase_connect($this->server . ':' . $this->dbname, $this->user, $sqlpassword, false, false, 3);
     return $this->db_connect_id ? $this->db_connect_id : $this->sql_error('');
 }
Esempio n. 8
0
 protected function connect()
 {
     if ($this->lnk === null) {
         $this->lnk = $this->settings->persist ? @\ibase_pconnect($this->settings->servername . $this->settings->database, $this->settings->username, $this->settings->password, strtoupper($this->settings->charset)) : @\ibase_connect($this->settings->servername . $this->settings->database, $this->settings->username, $this->settings->password, strtoupper($this->settings->charset));
         if ($this->lnk === false) {
             throw new DatabaseException('Connect error: ' . \ibase_errmsg());
         }
     }
 }
Esempio n. 9
0
 /**
  * Connect to server
  */
 function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
 {
     $this->persistency = $persistency;
     $this->user = $sqluser;
     $this->server = $sqlserver . ($port ? ':' . $port : '');
     $this->dbname = $database;
     $this->db_connect_id = $this->persistency ? @ibase_pconnect($this->server . ':' . $this->dbname, $this->user, $sqlpassword, false, false, 3) : @ibase_connect($this->server . ':' . $this->dbname, $this->user, $sqlpassword, false, false, 3);
     $this->service_handle = function_exists('ibase_service_attach') ? @ibase_service_attach($this->server, $this->user, $sqlpassword) : false;
     return $this->db_connect_id ? $this->db_connect_id : $this->sql_error('');
 }
Esempio n. 10
0
 function Buscar($q)
 {
     $conn = ibase_connect($this->src, $this->user, $this->password);
     $query = "SELECT INVE03.CVE_ART, INVE03.DESCR FROM inve03 where INVE03.DESCR LIKE '%" . $q . "%' AND INVE03.STATUS='A' OR INVE03.CVE_ART LIKE '%" . $q . "%' AND INVE03.STATUS='A' ORDER BY INVE03.CVE_ART";
     $inv = ibase_query($conn, $query);
     print "<table width='100%' border='0' cellspacing='0' cellpadding='0' style='font-family:Verdana; font-size:10; font-color:#CDCD'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td></td>\n\t\t\t\t\t<td></td>\n\t\t\t\t\t<td></td>\n\t\t\t\t</tr>";
     while ($IN = ibase_fetch_row($inv)) {
         print "<tr>" . "<td>" . $IN[1] . "</td>" . "<td><input style='border:0; background-color: #f9f9f9; font-family:Verdana; font-size:10; font-color:#CDCD; cursor:pointer' type='submit' id='valor2' value='" . $IN[0] . "' onClick='Resultado(\"" . $IN[0] . "\");'/></td>" . "</tr>";
     }
     print "</table>";
 }
Esempio n. 11
0
 function connect()
 {
     if ($this->linkId == 0) {
         $this->linkId = ibase_connect($this->dbHost . ":" . $this->dbName, $this->dbUser, $this->dbPass, 'ISO8859_1', 0, 3);
         if (!$this->linkId) {
             $this->updateError('DB::connect()<br />ibase_pconnect');
             return false;
         }
     }
     return true;
 }
Esempio n. 12
0
 /**
  * constructor(string $dsn)
  * Connect to Interbase/Firebird.
  */
 function DbSimple_Ibase($dsn)
 {
     $p = DbSimple_Generic::parseDSN($dsn);
     if (!is_callable('ibase_connect')) {
         return $this->_setLastError("-1", "Interbase/Firebird extension is not loaded", "ibase_connect");
     }
     $ok = $this->link = ibase_connect($p['host'] . (empty($p['port']) ? "" : ":" . $p['port']) . ':' . preg_replace('{^/}s', '', $p['path']), $p['user'], $p['pass'], isset($p['CHARSET']) ? $p['CHARSET'] : 'win1251', isset($p['BUFFERS']) ? $p['BUFFERS'] : 0, isset($p['DIALECT']) ? $p['DIALECT'] : 3, isset($p['ROLE']) ? $p['ROLE'] : '');
     $this->_resetLastError();
     if (!$ok) {
         return $this->_setDbError('ibase_connect()');
     }
 }
Esempio n. 13
0
 /**
  * Interbase constructor.
  * @param null $database
  * @param null $username
  * @param null $password
  * @param null $charset
  * @param null $buffers
  * @param null $dialect
  * @param null $role
  * @param null $sync
  */
 public function __construct($database = null, $username = null, $password = null, $charset = null, $buffers = null, $dialect = null, $role = null, $sync = null)
 {
     $this->database = $database;
     $this->username = $username;
     $this->password = $password;
     $this->charset = $charset;
     $this->buffers = $buffers;
     $this->dialect = $dialect;
     $this->role = $role;
     $this->sync = $sync;
     $this->resource = ibase_connect($database, $username, $password, $charset, $buffers, $dialect, $role, $sync);
 }
 function connect($server, $username, $password)
 {
     $this->_link = ibase_connect($server, $username, $password);
     if ($this->_link) {
         $url_parts = explode(':', $server);
         $this->service_link = ibase_service_attach($url_parts[0], $username, $password);
         $this->server_info = ibase_server_info($this->service_link, IBASE_SVC_SERVER_VERSION);
     } else {
         $this->errno = ibase_errcode();
         $this->error = ibase_errmsg();
     }
     return (bool) $this->_link;
 }
Esempio n. 15
0
 /**
  * @see ILumine_Connection::connect()
  */
 public function connect()
 {
     if ($this->conn_id && $this->state == self::OPEN) {
         Lumine_Log::debug('Utilizando conexao cacheada com ' . $this->getDatabase());
         return true;
     }
     $this->dispatchEvent(new Lumine_ConnectionEvent(Lumine_Event::PRE_CONNECT, $this));
     $hostString = $this->getHost();
     if ($this->getPort() != '') {
         // nao colocamos a porta uma vez que a string de conexao
         // nao suporta a informacao da porta
         //$hostString .=  ':' . $this->getPort();
     }
     $hostString = empty($hostString) ? $this->getDatabase() : $hostString . ':' . $this->getDatabase();
     if (isset($this->options['socket']) && $this->options['socket'] != '') {
         $hostString .= ':' . $this->options['socket'];
     }
     $flags = isset($this->options['flags']) ? $this->options['flags'] : null;
     if (isset($this->options['persistent']) && $this->options['persistent'] == true) {
         Lumine_Log::debug('Criando conexao persistente com ' . $this->getDatabase());
         $this->conn_id = @ibase_pconnect($hostString, $this->getUser(), $this->getPassword());
     } else {
         Lumine_Log::debug('Criando conexao com ' . $this->getDatabase());
         $this->conn_id = @ibase_connect($hostString, $this->getUser(), $this->getPassword());
     }
     if (!$this->conn_id) {
         $this->state = self::CLOSED;
         $msg = 'Nao foi possivel conectar no banco de dados: ' . $this->getDatabase() . ' - ' . $this->getErrorMsg();
         Lumine_Log::error($msg);
         $this->dispatchEvent(new Lumine_ConnectionEvent(Lumine_Event::CONNECTION_ERROR, $this, $msg));
         throw new Exception($msg);
         return false;
     }
     if (function_exists('ibase_timefmt')) {
         ibase_timefmt($this->ibase_datefmt, IBASE_DATE);
         if ($this->dialect == 1) {
             ibase_timefmt($this->ibase_datefmt, IBASE_TIMESTAMP);
         } else {
             ibase_timefmt($this->ibase_timestampfmt, IBASE_TIMESTAMP);
         }
         ibase_timefmt($this->ibase_timefmt, IBASE_TIME);
     } else {
         ini_set("ibase.timestampformat", $this->ibase_timestampfmt);
         ini_set("ibase.dateformat", $this->ibase_datefmt);
         ini_set("ibase.timeformat", $this->ibase_timefmt);
     }
     $this->state = self::OPEN;
     $this->dispatchEvent(new Lumine_ConnectionEvent(Lumine_Event::POS_CONNECT, $this));
     $this->setCharset($this->getCharset());
     return true;
 }
Esempio n. 16
0
 public function openConnection()
 {
     $database = "{$this->firebird->host}/{$this->account->firebird->port}:{$this->path->path}{$this->firebird->dir}{$this->account->idAccount}/{$this->account->idAccount}.FDB";
     //die($database);
     //$database = "{$this->firebird->host}{$this->path->path}{$this->firebird->dir}{$this->account->idAccount}/{$this->account->idAccount}.FDB";
     //print($database); die();
     //$database="190.147.164.82/8080:/home/silar/app/databases/{$this->account->idAccount}/{$this->account->idAccount}.FDB";
     $this->logger->log("Database: {$database}");
     $this->logger->log("Username: {$this->firebird->username}");
     $this->logger->log("Password: {$this->firebird->password}");
     //die($database);
     $this->connection = \ibase_connect($database, $this->firebird->username, $this->firebird->password);
     if (!$this->connection) {
         throw new \Exception("Acceso denegado");
     }
 }
Esempio n. 17
0
 function db_connect()
 {
     $hostname = 'localhost';
     $dialect = 3;
     $char_set = 'NONE';
     if (strcmp(trim($this->hostname), "") != 0) {
         $hostname = $this->hostname;
     }
     if (isset($this->dialect) && $this->dialect == 1) {
         $dialect = $this->dialect;
     }
     if (strcmp(trim($this->char_set), "") != 0) {
         $char_set = $this->char_set;
     }
     $dbpath = $hostname . ":" . $this->database;
     return @ibase_connect($dbpath, $this->username, $this->password, $char_set, 0, $dialect);
 }
Esempio n. 18
0
 function DBAQuery(&$db, $database_file, $query)
 {
     if (!function_exists("ibase_connect")) {
         return $db->SetError("DBA query", "Interbase support is not available in this PHP configuration");
     }
     if (!isset($db->options[$option = "DBAUser"]) || !isset($db->options[$option = "DBAPassword"])) {
         return $db->SetError("DBA query", "it was not specified the Interbase {$option} option");
     }
     $database = $db->host . (strcmp($database_file, "") ? ":" . $database_file : "");
     if (($connection = @ibase_connect($database, $db->options["DBAUser"], $db->options["DBAPassword"])) <= 0) {
         return $db->SetError("DBA query", "Could not connect to Interbase server ({$database}): " . ibase_errmsg());
     }
     if (!($success = @ibase_query($connection, $query))) {
         $db->SetError("DBA query", "Could not execute query ({$query}): " . ibase_errmsg());
     }
     ibase_close($connection);
     return $success;
 }
Esempio n. 19
0
 /**
  * Connects to a database.
  * @return void
  * @throws Dibi\Exception
  */
 public function connect(array &$config)
 {
     Dibi\Helpers::alias($config, 'database', 'db');
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         // default values
         $config += ['username' => ini_get('ibase.default_password'), 'password' => ini_get('ibase.default_user'), 'database' => ini_get('ibase.default_db'), 'charset' => ini_get('ibase.default_charset'), 'buffers' => 0];
         if (empty($config['persistent'])) {
             $this->connection = @ibase_connect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']);
             // intentionally @
         } else {
             $this->connection = @ibase_pconnect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']);
             // intentionally @
         }
         if (!is_resource($this->connection)) {
             throw new Dibi\DriverException(ibase_errmsg(), ibase_errcode());
         }
     }
 }
Esempio n. 20
0
 /**
  * Connect to server
  */
 function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
 {
     $this->persistency = $persistency;
     $this->user = $sqluser;
     $this->server = $sqlserver . ($port ? ':' . $port : '');
     $this->dbname = str_replace('\\', '/', $database);
     // There are three possibilities to connect to an interbase db
     if (!$this->server) {
         $use_database = $this->dbname;
     } else {
         if (strpos($this->server, '//') === 0) {
             $use_database = $this->server . $this->dbname;
         } else {
             $use_database = $this->server . ':' . $this->dbname;
         }
     }
     $this->db_connect_id = $this->persistency ? @ibase_pconnect($use_database, $this->user, $sqlpassword, false, false, 3) : @ibase_connect($use_database, $this->user, $sqlpassword, false, false, 3);
     $this->service_handle = function_exists('ibase_service_attach') && $this->server ? @ibase_service_attach($this->server, $this->user, $sqlpassword) : false;
     return $this->db_connect_id ? $this->db_connect_id : $this->sql_error('');
 }
 /**
  * Connect
  *
  * @param   bool reconnect default FALSE
  * @return  bool success
  * @throws  rdbms.SQLConnectException
  */
 public function connect($reconnect = FALSE)
 {
     if (is_resource($this->handle)) {
         return TRUE;
     }
     // Already connected
     if (!$reconnect && FALSE === $this->handle) {
         return FALSE;
     }
     // Previously failed connecting
     $db = $this->dsn->getHost() . ':' . $this->dsn->getDatabase();
     if ($this->flags & DB_PERSISTENT) {
         $this->handle = ibase_pconnect($db, $this->dsn->getUser(), $this->dsn->getPassword(), 'ISO8859_1');
     } else {
         $this->handle = ibase_connect($db, $this->dsn->getUser(), $this->dsn->getPassword(), 'ISO8859_1');
     }
     if (!is_resource($this->handle)) {
         throw new SQLConnectException(trim(ibase_errmsg()), $this->dsn);
     }
     $this->_obs && $this->notifyObservers(new DBEvent(__FUNCTION__, $reconnect));
     return TRUE;
 }
Esempio n. 22
0
 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'database', 'db');
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         // default values
         if (!isset($config['username'])) {
             $config['username'] = ini_get('ibase.default_password');
         }
         if (!isset($config['password'])) {
             $config['password'] = ini_get('ibase.default_user');
         }
         if (!isset($config['database'])) {
             $config['database'] = ini_get('ibase.default_db');
         }
         if (!isset($config['charset'])) {
             $config['charset'] = ini_get('ibase.default_charset');
         }
         if (!isset($config['buffers'])) {
             $config['buffers'] = 0;
         }
         DibiDriverException::tryError();
         if (empty($config['persistent'])) {
             $this->connection = ibase_connect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']);
             // intentionally @
         } else {
             $this->connection = ibase_pconnect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']);
             // intentionally @
         }
         if (DibiDriverException::catchError($msg)) {
             throw new DibiDriverException($msg, ibase_errcode());
         }
         if (!is_resource($this->connection)) {
             throw new DibiDriverException(ibase_errmsg(), ibase_errcode());
         }
     }
 }
Esempio n. 23
0
 /**
  * Connect to server
  */
 function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
 {
     $this->persistency = $persistency;
     $this->user = $sqluser;
     $this->server = $sqlserver . ($port ? ':' . $port : '');
     $this->dbname = str_replace('\\', '/', $database);
     // There are three possibilities to connect to an interbase db
     if (!$this->server) {
         $use_database = $this->dbname;
     } else {
         if (strpos($this->server, '//') === 0) {
             $use_database = $this->server . $this->dbname;
         } else {
             $use_database = $this->server . ':' . $this->dbname;
         }
     }
     if ($this->persistency) {
         if (!function_exists('ibase_pconnect')) {
             $this->connect_error = 'ibase_pconnect function does not exist, is interbase extension installed?';
             return $this->sql_error('');
         }
         $this->db_connect_id = @ibase_pconnect($use_database, $this->user, $sqlpassword, false, false, 3);
     } else {
         if (!function_exists('ibase_connect')) {
             $this->connect_error = 'ibase_connect function does not exist, is interbase extension installed?';
             return $this->sql_error('');
         }
         $this->db_connect_id = @ibase_connect($use_database, $this->user, $sqlpassword, false, false, 3);
     }
     // Do not call ibase_service_attach if connection failed,
     // otherwise error message from ibase_(p)connect call will be clobbered.
     if ($this->db_connect_id && function_exists('ibase_service_attach') && $this->server) {
         $this->service_handle = @ibase_service_attach($this->server, $this->user, $sqlpassword);
     } else {
         $this->service_handle = false;
     }
     return $this->db_connect_id ? $this->db_connect_id : $this->sql_error('');
 }
Esempio n. 24
0
 function Connect()
 {
     if (!$this->intConn) {
         if ($this->intDebug) {
             echo "Establishing connection...\t\t\n";
         }
         if ($this->intUsePersistent) {
             $this->intConn = @ibase_pconnect($this->strHost . ':' . $this->strDatabase, $this->strUser, $this->strPassword) or die("Error:" . ibase_errmsg() . "<br>\n");
         } else {
             $this->intConn = @ibase_connect($this->strHost . ':' . $this->strDatabase, $this->strUser, $this->strPassword) or die("Error:" . ibase_errmsg() . "<br>\n");
         }
     }
     if (!$this->intConn) {
         if ($this->intDebug) {
             echo "Error establishing connection!\n";
         }
     } else {
         if ($this->intDebug) {
             echo "Connection established!<br>";
         }
     }
     return $this->intConn;
 }
 /**
  * Connect
  *
  * @param   bool reconnect default FALSE
  * @return  bool success
  * @throws  rdbms.SQLConnectException
  */
 public function connect($reconnect = false)
 {
     if (is_resource($this->handle)) {
         return true;
     }
     // Already connected
     if (!$reconnect && false === $this->handle) {
         return false;
     }
     // Previously failed connecting
     $this->_obs && $this->notifyObservers(new \rdbms\DBEvent(\rdbms\DBEvent::CONNECT, $reconnect));
     $db = $this->dsn->getHost() . ':' . $this->dsn->getDatabase();
     if ($this->flags & DB_PERSISTENT) {
         $this->handle = ibase_pconnect($db, $this->dsn->getUser(), $this->dsn->getPassword(), 'UTF_8');
     } else {
         $this->handle = ibase_connect($db, $this->dsn->getUser(), $this->dsn->getPassword(), 'UTF_8');
     }
     if (!is_resource($this->handle)) {
         throw new \rdbms\SQLConnectException(trim(ibase_errmsg()), $this->dsn);
     }
     $this->_obs && $this->notifyObservers(new \rdbms\DBEvent(\rdbms\DBEvent::CONNECTED, $reconnect));
     return true;
 }
Esempio n. 26
0
 /**
  * @brief DB 접속
  **/
 function _connect()
 {
     // db 정보가 없으면 무시
     if (!$this->hostname || !$this->port || !$this->userid || !$this->password || !$this->database) {
         return;
     }
     //if(strpos($this->hostname, ':')===false && $this->port) $this->hostname .= ':'.$this->port;
     // 접속시도
     $host = $this->hostname . "/" . $this->port . ":" . $this->database;
     $this->fd = @ibase_connect($host, $this->userid, $this->password);
     if (ibase_errmsg()) {
         $this->setError(ibase_errcode(), ibase_errmsg());
         return $this->is_connected = false;
     }
     // Firebird 버전 확인후 2.0 이하면 오류 표시
     if (($service = ibase_service_attach($this->hostname, $this->userid, $this->password)) != FALSE) {
         // get server version and implementation strings
         $server_info = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
         ibase_service_detach($service);
     } else {
         $this->setError(ibase_errcode(), ibase_errmsg());
         @ibase_close($this->fd);
         return $this->is_connected = false;
     }
     $pos = strpos($server_info, "Firebird");
     if ($pos !== false) {
         $ver = substr($server_info, $pos + strlen("Firebird"));
         $ver = trim($ver);
     }
     if ($ver < "2.0") {
         $this->setError(-1, "XE cannot be installed under the version of firebird 2.0. Current firebird version is " . $ver);
         @ibase_close($this->fd);
         return $this->is_connected = false;
     }
     // 접속체크
     $this->is_connected = true;
 }
Esempio n. 27
0
/**
 * Abra a conexão com o banco de dados firebird
 *
 * <code>
 * $firebirdHandle = dbOpen_firebird("firebird", "database", "user", "password");
 * </code>
 *
 * @param string $dbHost string de conexão com o banco de dados
 * @param string $dbDatabase[optional] string database utilizado
 * @param string $dbUser[optional] nome do usuário
 * @param string $dbPassword[optional] senha do usuário
 *
 * @return array com o handleId e o nome do driver
 *
 * @since Versão 1.0
 */
function dbOpen_firebird(&$dbHandle)
{
    $debugBackTrace = debug_backtrace();
    $debugFile = basename($debugBackTrace[1]["file"]);
    $debugFunction = $debugBackTrace[1]["function"];
    $dbDriver = $dbHandle[dbHandleDriver];
    if (!function_exists("ibase_connect")) {
        echo "<span style=\"text-align: left;\"><pre><b>{$dbDriver} - {$debugFile} - {$debugFunction}() - Connect</b>:" . "<br />extension=<b>php_interbase_firebird.dll</b> is not loaded";
        echo "<hr />" . debugBackTrace();
        echo "</pre></span>";
        die;
    }
    $dbDatabase = $dbHandle[dbHandleDatabase];
    $dbUser = $dbHandle[dbHandleUser];
    $dbPassword = $dbHandle[dbHandlePassword];
    // @TODO Incluir tratamento para ver se o driver está carregado
    if (!($firebirdConn = @ibase_connect($dbDatabase, $dbUser, $dbPassword))) {
        echo "<span style=\"text-align: left;\"><pre><b>{$dbDriver} - {$debugFile} - {$debugFunction}() - Connect</b>:" . "<br /><b>Database</b>: " . $dbDatabase . "<br /><b>Message</b>: [" . ibase_errmsg() . "]";
        echo "<hr />" . debugBackTrace();
        echo "</pre></span>";
        die;
    }
    return $firebirdConn;
}
Esempio n. 28
0
function sti_firebird_get_data($connection_string, $data_source_name, $query)
{
    $info = sti_firebird_parse_connection_string($connection_string);
    $link = ibase_connect($info["host"] . ":" . $info["database"], $info["user_id"], $info["password"]) or die("ServerError:Could not connect to host '" . $info["host"] . "', database '" . $info["database"] . "'");
    $query = sti_parse_query_parameters($query);
    $result = ibase_query($link, $query) or die("ServerError:Data not found");
    $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Database>";
    $count = ibase_num_fields($result);
    for ($fid = 0; $fid < $count; $fid++) {
        $field_info = ibase_field_info($result, $fid);
        $columns[$fid] = $field_info['alias'];
    }
    while ($row = ibase_fetch_assoc($result)) {
        $xml_output .= "<{$data_source_name}>";
        foreach ($columns as $column) {
            $value = $row[$column];
            $value = str_replace("&", "&amp;", $value);
            $value = str_replace("<", "&lt;", $value);
            $value = str_replace(">", "&gt;", $value);
            $xml_output .= "<{$column}>{$value}</{$column}>";
        }
        $xml_output .= "</{$data_source_name}>";
    }
    $xml_output .= "</Database>";
    ibase_free_result($result);
    ibase_close($link);
    return $xml_output;
}
Esempio n. 29
0
/**
 * Opens up a database connection.
 *
 * Use a pooled connection if the db supports it and
 * the <var>db_persistent</var> setting is enabled.
 *
 * <b>Notes:</b>
 * - The database type is determined by the global variable
 *   <var>db_type</var>
 * - For ODBC, <var>$host</var> is ignored, <var>$database</var> = DSN
 * - For Oracle, <var>$database</var> = tnsnames name
 * - Use the {@link dbi_error()} function to get error information if the connection
 *   fails
 *
 * @param string $host     Hostname of database server
 * @param string $login    Database login
 * @param string $password Database login password
 * @param string $database Name of database
 * 
 * @return resource The connection
 */
function dbi_connect($host, $login, $password, $database)
{
    if (strcmp($GLOBALS["db_type"], "mysql") == 0) {
        if ($GLOBALS["db_persistent"]) {
            $c = mysql_pconnect($host, $login, $password);
        } else {
            $c = mysql_connect($host, $login, $password);
        }
        if ($c) {
            if (!mysql_select_db($database)) {
                return false;
            }
            return $c;
        } else {
            return false;
        }
    } else {
        if (strcmp($GLOBALS["db_type"], "mysqli") == 0) {
            if ($GLOBALS["db_persistent"]) {
                $c = @mysqli_connect($host, $login, $password, $database);
            } else {
                $c = @mysqli_connect($host, $login, $password, $database);
            }
            if ($c) {
                /*
                if ( ! mysqli_select_db ( $c, $database ) )
                  return false;
                */
                $GLOBALS["db_connection"] = $c;
                return $c;
            } else {
                return false;
            }
        } else {
            if (strcmp($GLOBALS["db_type"], "mssql") == 0) {
                if ($GLOBALS["db_persistent"]) {
                    $c = mssql_pconnect($host, $login, $password);
                } else {
                    $c = mssql_connect($host, $login, $password);
                }
                if ($c) {
                    if (!mssql_select_db($database)) {
                        return false;
                    }
                    return $c;
                } else {
                    return false;
                }
            } else {
                if (strcmp($GLOBALS["db_type"], "oracle") == 0) {
                    if (strlen($host) && strcmp($host, "localhost")) {
                        $c = OCIPLogon("{$login}@{$host}", $password, $database);
                    } else {
                        $c = OCIPLogon($login, $password, $database);
                    }
                    $GLOBALS["oracle_connection"] = $c;
                    return $c;
                } else {
                    if (strcmp($GLOBALS["db_type"], "postgresql") == 0) {
                        if (strlen($password)) {
                            if (strlen($host)) {
                                $dbargs = "host={$host} dbname={$database} user={$login} password={$password}";
                            } else {
                                $dbargs = "dbname={$database} user={$login} password={$password}";
                            }
                        } else {
                            if (strlen($host)) {
                                $dbargs = "host={$host} dbname={$database} user={$login}";
                            } else {
                                $dbargs = "dbname={$database} user={$login}";
                            }
                        }
                        if ($GLOBALS["db_persistent"]) {
                            $c = pg_pconnect($dbargs);
                        } else {
                            $c = pg_connect($dbargs);
                        }
                        $GLOBALS["postgresql_connection"] = $c;
                        if (!$c) {
                            echo "Error connecting to database\n";
                            exit;
                        }
                        return $c;
                    } else {
                        if (strcmp($GLOBALS["db_type"], "odbc") == 0) {
                            if ($GLOBALS["db_persistent"]) {
                                $c = odbc_pconnect($database, $login, $password);
                            } else {
                                $c = odbc_connect($database, $login, $password);
                            }
                            $GLOBALS["odbc_connection"] = $c;
                            return $c;
                        } else {
                            if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) {
                                if ($GLOBALS["db_persistent"]) {
                                    $c = db2_pconnect($database, $login, $password);
                                } else {
                                    $c = db2_connect($database, $login, $password);
                                }
                                $GLOBALS["ibm_db2_connection"] = $c;
                                return $c;
                            } else {
                                if (strcmp($GLOBALS["db_type"], "ibase") == 0) {
                                    $host = $host . ":" . $database;
                                    if ($GLOBALS["db_persistent"]) {
                                        $c = ibase_pconnect($host, $login, $password);
                                    } else {
                                        $c = ibase_connect($host, $login, $password);
                                    }
                                    return $c;
                                } else {
                                    if (empty($GLOBALS["db_type"])) {
                                        dbi_fatal_error("dbi_connect(): db_type not defined.");
                                    } else {
                                        dbi_fatal_error("dbi_connect(): invalid db_type '" . $GLOBALS["db_type"] . "'");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Esempio n. 30
0
 /**
  * Non-persistent database connection
  *
  * @param	bool	$persistent
  * @return	resource
  */
 public function db_connect($persistent = FALSE)
 {
     return $persistent === TRUE ? ibase_pconnect($this->hostname . ':' . $this->database, $this->username, $this->password, $this->char_set) : ibase_connect($this->hostname . ':' . $this->database, $this->username, $this->password, $this->char_set);
 }