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')); } }
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(''); }
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()); } } }
/** * 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(''); }
/** Métodos de Conexión y Consulta a la BD * */ function dbConnect() { //C:\Archivos de programa\Archivos comunes\Aspel\Sistemas Aspel\CAJA3.50\Datos $DB = "C:\\Archivos de programa\\Archivos comunes\\Aspel\\Sistemas Aspel\\CAJA3.50\\Ejemplos\\Ejemplos.FDB"; //Voy a utilizar el login y el password que trae Interbase por defecto. $User = "******"; $Pass = "******"; //"Prueba de conexión a la bd"; $cxn = ibase_pconnect($DB, $User, $Pass) or die("Error al conectarse a la base de datos"); return $cxn; }
/** * @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; }
function dbQuery($query, $show_errors = true, $all_results = true, $show_output = true) { if ($show_errors) { error_reporting(E_ALL); } else { error_reporting(E_PARSE); } // Connect to the Firebird/Interbase Sybase database management system $link = ibase_pconnect("/var/www/sqlmap/dbs/firebird/testdb.fdb", "SYSDBA", "testpass"); if (!$link) { die(ibase_errmsg()); } // Print results in HTML print "<html><body>\n"; // Print SQL query to test sqlmap '--string' command line option //print "<b>SQL query:</b> " . $query . "<br>\n"; // Perform SQL injection affected query $result = ibase_query($link, $query); if (!$result) { if ($show_errors) { print "<b>SQL error:</b> " . ibase_errmsg() . "<br>\n"; } exit(1); } print "<b>SQL results:</b>\n"; print "<table border=\"1\">\n"; while ($line = ibase_fetch_assoc($result)) { // This must stay here for Firebird if (!$show_output) { exit(1); } print "<tr>"; foreach ($line as $col_value) { print "<td>" . $col_value . "</td>"; } print "</tr>\n"; if (!$all_results) { break; } } print "</table>\n"; print "</body></html>"; }
/** * 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()); } } }
/** * 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; }
/** * 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()); } } }
/** * 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(''); }
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; }
function gcms_pconnect($server, $user, $password, $database) { global $fbdb; $fbdb = ibase_pconnect("{$server}:{$database}", $user, $password, '', 0, 3); return $fbdb; }
/** * Persistent database connection * * @return resource */ public function db_pconnect() { return @ibase_pconnect($this->hostname . ':' . $this->database, $this->username, $this->password, $this->char_set); }
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { if ($this->charSet) { $this->_connectionID = ibase_pconnect($argHostname, $argUsername, $argPassword, $this->charSet); } else { $this->_connectionID = ibase_pconnect($argHostname, $argUsername, $argPassword); } if ($this->_connectionID === false) { $this->_handleerror(); return false; } return true; }
public function connect() { $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 Exception('Connect error: ' . ibase_errmsg()); } return true; }
function pconnect() { $this->error = ""; //Set the errors to none if ($this->debug) { $this->debugmsg("Connecting (PConnect) to " . $this->dbtype . " database....", "blue"); } switch ($this->dbtype) { /* Firebird Functionality */ case "firebird": ini_set("ibase.dateformat", $this->dateformat); ini_set("ibase.timestampformat", $this->datetimeformat); $this->dbh = ibase_pconnect($this->dbpath, $this->username, $this->password); break; /* SQLite Functionality */ /* SQLite Functionality */ case "sqlite": define("CDE_ASSOC", SQLITE_ASSOC); define("CDE_NUM", SQLITE_NUM); define("CDE_BOTH", SQLITE_BOTH); putenv("TMP=" . $this->tmppath); $this->dbh = sqlite_open($this->dbpath); break; /* DBASE Functionality */ /* DBASE Functionality */ case "dbase": $this->dbh = dbase_open($this->dbpath, 2); break; /* MYSQL Functionality */ /* MYSQL Functionality */ case "mysql": $connection = explode(":", $this->dbpath); $this->dbh = mysql_connect($connection[0], $this->username, $this->password); mysql_select_db($connection[1]); break; /* Oracle Functionality */ /* Oracle Functionality */ case "oracle": $this->dbh = oci_pconnect($this->username, $this->password, $this->dbpath); break; /* MSSQL Functionality */ /* MSSQL Functionality */ case "mssql": define("CDE_ASSOC", MSSQL_ASSOC, true); define("CDE_NUM", MSSQL_NUM, true); define("CDE_BOTH", MSSQL_BOTH, true); $connection = explode(":", $this->dbpath); $this->dbh = mssql_connect($connection[0], $this->username, $this->password); mssql_select_db($connection[1]); break; /* PGSQL Functionality */ /* PGSQL Functionality */ case "pgsql": $connection = explode(":", $this->dbpath); $this->dbh = pg_connect("host=" . $connection[0] . " dbname=" . $connection[1] . " user="******" pass="******""); break; } //Define defaults for all databases that don't suport fetch_array define("CDE_ASSOC", 1); define("CDE_NUM", 2); define("CDE_BOTH", 3); define("CDE_INSERT", 0); define("CDE_UPDATE", 1); define("CDE_DELETE", 2); if ($this->debug) { if ($this->dbh) { $this->debugmsg("Connected (pconnect) to " . $this->dbtype . " database....", "green"); } else { $this->debugmsg("Failed to connect (pconnect) " . $this->dbtype . " database....", "red"); exit; } //if we can't connect don't go on. } }
function dbi_connect($host, $login, $password, $database, $lazy = true) { global $db_cache_count, $db_connection_info, $db_query_count, $old_textlimit, $old_textsize, $db_sqlite_error_str; $db_cache_count = $db_query_count = 0; if (!isset($db_connection_info)) { $db_connection_info = array(); } $db_connection_info['connected'] = false; $db_connection_info['connection'] = 0; $db_connection_info['database'] = $database; $db_connection_info['host'] = $host; $db_connection_info['login'] = $login; $db_connection_info['password'] = $password; // mysqli requires $db_connection_info['connection'] to be set if (strcmp($GLOBALS['db_type'], 'mysqli') == 0) { $lazy == false; } // Lazy connections... do not connect until 1st call to dbi_query. if ($lazy) { // echo "<!-- Waiting on db connection made (lazy) -->\nRETURN!<br />"; return true; } if (strcmp($GLOBALS['db_type'], 'mysql') == 0) { $c = $GLOBALS['db_persistent'] ? mysql_pconnect($host, $login, $password) : mysql_connect($host, $login, $password); if ($c) { if (!mysql_select_db($database)) { return false; } $db_connection_info['connected'] = true; $db_connection_info['connection'] = $c; return $c; } else { return false; } } elseif (strcmp($GLOBALS['db_type'], 'mysqli') == 0) { $c = new mysqli($host, $login, $password, $database); if ($c) { if (mysqli_connect_errno() && !empty($database)) { return false; } $db_connection_info['connected'] = true; $db_connection_info['connection'] = $GLOBALS['db_connection'] = $c; return $c; } else { return false; } } elseif (strcmp($GLOBALS['db_type'], 'mssql') == 0) { static $old_textlimit, $old_textsize; $old_textlimit = ini_get('mssql.textlimit'); $old_textsize = ini_get('mssql.textsize'); ini_set('mssql.textlimit', '2147483647'); ini_set('mssql.textsize', '2147483647'); $c = $GLOBALS['db_persistent'] ? mssql_pconnect($host, $login, $password) : mssql_connect($host, $login, $password); if ($c) { if (!mssql_select_db($database)) { return false; } $db_connection_info['connected'] = true; $db_connection_info['connection'] = $c; return $c; } else { return false; } } elseif (strcmp($GLOBALS['db_type'], 'oracle') == 0) { $_ora_conn_func = 'OCI' . ($GLOBALS['db_persistent'] ? 'P' : '') . 'Logon'; $c = $_ora_conn_func($login, $password, strlen($host) && strcmp($host, 'localhost') ? '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = ' . $host . ' ) (PORT = 1521))) (CONNECT_DATA = (SID = ' . $database . ' )))' : $database); unset($_ora_conn_func); $db_connection_info['connected'] = true; $db_connection_info['connection'] = $GLOBALS['oracle_connection'] = $c; return $c; } elseif (strcmp($GLOBALS['db_type'], 'postgresql') == 0) { $dbargs = (strlen($host) ? 'host=' . "{$host} " : '') . 'dbname=' . $database . ' user='******' password='******''); $c = $GLOBALS['db_persistent'] ? pg_pconnect($dbargs) : pg_connect($dbargs); $GLOBALS['postgresql_connection'] = $c; if (!$c) { return false; } $db_connection_info['connected'] = true; $db_connection_info['connection'] = $c; return $c; } elseif (strcmp($GLOBALS['db_type'], 'odbc') == 0) { $c = $GLOBALS['db_persistent'] ? odbc_pconnect($database, $login, $password) : odbc_connect($database, $login, $password); $db_connection_info['connected'] = true; $db_connection_info['connection'] = $GLOBALS['odbc_connection'] = $c; return $c; } elseif (strcmp($GLOBALS['db_type'], 'ibm_db2') == 0) { $c = $GLOBALS['db_persistent'] ? db2_pconnect($database, $login, $password) : db2_connect($database, $login, $password); $db_connection_info['connected'] = true; $db_connection_info['connection'] = $GLOBALS['ibm_db2_connection'] = $c; return $c; } elseif (strcmp($GLOBALS['db_type'], 'ibase') == 0) { $host = $host . ':' . $database; $c = $GLOBALS['db_persistent'] ? ibase_pconnect($host, $login, $password) : ibase_connect($host, $login, $password); $db_connection_info['connected'] = true; $db_connection_info['connection'] = $c; return $c; } elseif (strcmp($GLOBALS['db_type'], 'sqlite') == 0) { $c = $GLOBALS['db_persistent'] ? sqlite_popen($database, 0666, $db_sqlite_error_str) : sqlite_open($database, 0666, $db_sqlite_error_str); if (!$c) { echo translate('Error connecting to database') . ": " . $db_sqlite_error_str . ".\n"; exit; } $db_connection_info['connected'] = true; $db_connection_info['connection'] = $GLOBALS['sqlite_c'] = $c; return $c; } else { dbi_fatal_error('dbi_connect (): ' . (empty($GLOBALS['db_type']) ? translate('db_type not defined.') : translate('invalid db_type') . ' ' . $GLOBALS['db_type'] . '.')); } }
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { if (!function_exists('ibase_pconnect')) { return false; } if ($argDatabasename) { $argHostname .= ':' . $argDatabasename; } $this->_connectionID = ibase_pconnect($argHostname, $argUsername, $argPassword, $this->charSet, $this->buffers, $this->dialect); if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html $this->replaceQuote = "''"; } if ($this->_connectionID === false) { $this->_handleerror(); return false; } ibase_timefmt($this->ibase_timefmt); return true; }
/** * Persistent database connection * * @access private called by the base class * @return resource */ function db_pconnect() { $hoststring = $this->hostname . ':' . $this->database; return @ibase_pconnect($hoststring, $this->username, $this->password, $this->char_set, $this->dialect); }
/** * This function opens a connection using the data source provided. * * @access public * @override * @throws Throwable_Database_Exception indicates that there is problem with * opening the connection * * @see http://www.destructor.de/firebird/charsets.htm */ public function open() { if (!$this->is_connected()) { $connection_string = $this->data_source->host; if (!preg_match('/^localhost$/i', $connection_string)) { $port = $this->data_source->port; if (!empty($port)) { $connection_string .= '/' . $port; } } $connection_string .= ':' . $this->data_source->database; $username = $this->data_source->username; $password = $this->data_source->password; $charset = $this->data_source->charset; if (!empty($charset)) { $charset = strtoupper($charset); } $role = !empty($this->data_source->role) ? $this->data_source->role : NULL; $this->resource = $this->data_source->is_persistent() ? @ibase_pconnect($connection_string, $username, $password, $charset, 0, 3, $role) : @ibase_connect($connection_string, $username, $password, $charset, 0, 3, $role); if ($this->resource === FALSE) { throw new Throwable_Database_Exception('Message: Failed to establish connection. Reason: :reason', array(':reason' => @ibase_errmsg())); } } }
<html> <head> <title>PHP und InterBase</title> </head> <body> <h1>PHP und InterBase/Firebird</h1> <table border="1"> <tr> <th>Interpret</th> <th>Titel</th> <th>Jahr</th> </tr> <?php $db = ibase_pconnect("/Applications/XAMPP/xamppfiles/var/firebird/cdcol.gdb", "oswald", "geheim"); $query = "SELECT * FROM cds"; $result = ibase_query($query); if ($result) { while ($row = ibase_fetch_assoc($result)) { echo "<tr>"; echo "<td>" . $row['INTERPRET'] . "</td>"; echo "<td>" . $row['TITEL'] . "</td>"; echo "<td>" . $row['JAHR'] . "</td>"; echo "</tr>"; } } else { echo ibase_errmsg(); } ?> </table> </body> </html>
/** * 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); }
/** * Persistent database connection * * @access private called by the base class * @return resource */ function db_pconnect() { $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_pconnect($dbpath, $this->username, $this->password, $char_set, 0, $dialect); }
/** * 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"] . "'"); } } } } } } } } } }
<html> <head> <title>PHP und InterBase</title> </head> <body> <h1>PHP und InterBase/Firebird</h1> <table border="1"> <tr> <th>Interpret</th> <th>Titel</th> <th>Jahr</th> </tr> <?php $db = ibase_pconnect("/opt/lampp/var/firebird/cdcol.gdb", "oswald", "geheim"); $query = "SELECT * FROM cds"; $result = ibase_query($query); if ($result) { while ($row = ibase_fetch_assoc($result)) { echo "<tr>"; echo "<td>" . $row['INTERPRET'] . "</td>"; echo "<td>" . $row['TITEL'] . "</td>"; echo "<td>" . $row['JAHR'] . "</td>"; echo "</tr>"; } } else { echo ibase_errmsg(); } ?> </table> </body> </html>