This is a discussion on DB Connection in PHP within the PHP Programming forums, part of the Web Development category; Hi The example code for the mysql_thread_id() is given below PHP Code: <?php $link = mysql_connect('localhost', '...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi The example code for the mysql_thread_id() is given below PHP Code: Falcon ![]() |
| Sponsored Links |
| |||
| Hi mysql_tablename () This function deprecated. It is preferable to use mysql_query() to issue a SQL SHOW TABLES [FROM db_name] [LIKE 'pattern'] statement instead. Regards Falcon ![]() |
| |||
| Hi Example for the mysql_tablename() is given below PHP Code: Falcon ![]() |
| |||
| Hi mysql_stat() mysql_stat() returns the current server status. for example PHP Code: Code: Array
(
[0] => Uptime: 5380
[1] => Threads: 2
[2] => Questions: 1321299
[3] => Slow queries: 0
[4] => Opens: 26
[5] => Flush tables: 1
[6] => Open tables: 17
[7] => Queries per second avg: 245.595
) Falcon ![]() |
| |||
| Hi Alternative mysql_stat() example PHP Code: Code: back_log = 50 basedir = /usr/local/ bdb_cache_size = 8388600 bdb_log_buffer_size = 32768 bdb_home = /var/db/mysql/ bdb_max_lock = 10000 bdb_logdir = bdb_shared_data = OFF bdb_tmpdir = /var/tmp/ ... Falcon ![]() |
| |||
| mysql_list_dbs() lists databases available on a MySQL server For e.g PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| mysql_db_name() retrieve the database name from a call to mysql_list_dbs(). We can use this function as follows PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| mysql_list_fields() Retrieves information about the given table name. This function is deprecated. It is preferable to use mysql_query() to issue a SQL SHOW COLUMNS FROM table [LIKE 'name'] statement instead.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Alternate to deprecated mysql_list_fields() PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| In the above way we can use mysql_list_processes() to list various MySQL processes For example: PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| here the example for mysql_list_tables() function PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Oracle functions allow you to access Oracle 10, Oracle 9, Oracle 8 and Oracle 7 databases using the Oracle Call Interface (OCI). They support binding of PHP variables to Oracle placeholders, have full LOB, FILE and ROWID support, and allow you to use user-supplied define variables.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| You will need the Oracle client libraries to use this extension. Windows users will need at least Oracle version 8.1 to use the php_oci8.dll dll. The most convenient way to install all the required files is to use Oracle Instant Client, which is available from here: Instant Client. Instant Client does not need ORACLE_SID or ORACLE_HOME environment variables set. You still may need to set LD_LIBRARY_PATH and NLS_LANG, though. Before using this extension, make sure that you have set up your Oracle environment variables properly for the Oracle user, as well as your web daemon user. These variables should be set up before you start your web-server. The variables you might need to set are as follows:
For less frequently used Oracle environment variables such as TNS_ADMIN, TWO_TASK, ORA_TZFILE, and the various Oracle globalization settings like ORA_NLS33, ORA_NLS10 and the NLS_* variables refer to Oracle documentation.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| After setting up the environment variables for your webserver user, be sure to also add the webserver user (nobody, www) to the oracle group. If your webserver doesn't start or crashes at startup: Check that Apache is linked with the pthread library: Code:
# ldd /www/apache/bin/httpd
libpthread.so.0 => /lib/libpthread.so.0 (0x4001c000)
libm.so.6 => /lib/libm.so.6 (0x4002f000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x4004c000)
libdl.so.2 => /lib/libdl.so.2 (0x4007a000)
libc.so.6 => /lib/libc.so.6 (0x4007e000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) Code: # cd /usr/src/apache_1.3.xx # make clean # LIBS=-lpthread ./config.status # make # make install Please note that on some systems, like UnixWare it is libthread instead of libpthread. PHP and Apache have to be configured with EXTRA_LIBS=-lthread.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| The oci8 extension provides you with 3 different functions for connecting to Oracle. It is up to you to use the most appropriate function for your application, and the information in this section is intended to help you make an informed choice. Connecting to an Oracle server is a reasonably expensive operation, in terms of the time that it takes to complete. The oci_pconnect() function uses a persistent cache of connections that can be re-used across different script requests. This means that you will typically only incur the connection overhead once per php process (or apache child).
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| If your application connects to Oracle using a different set of credentials for each web user, the persistent cache employed by oci_pconnect() will become less useful as the number of concurrent users increases, to the point where it may start to adversely affect the overall performance of your Oracle server due to maintaining too many idle connections. If your application is structured in this way, it is recommended that you either tune your application using the oci8.max_persistent and oci8.persistent_timeout configuration settings (these will give you control over the persistent connection cache size and lifetime) or use oci_connect() instead.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Both oci_connect() and oci_pconnect() employ a connection cache; if you make multiple calls to oci_connect(), using the same parameters, in a given script, the second and subsequent calls return the existing connection handle. The cache used by oci_connect() is cleaned up at the end of the script run, or when you explicitly close the connection handle. oci_pconnect() has similar behaviour, although its cache is maintained separately and survives between requests.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| This caching feature is important to remember, because it gives the appearance that the two handles are not transactionally isolated (they are in fact the same connection handle, so there is no isolation of any kind). If your application needs two separate, transactionally isolated connections, you should use oci_new_connect(). oci_new_connect() always creates a new connection to the Oracle server, regardless of what other connections might already exist. High traffic web applications should try to avoid using oci_new_connect(), especially in the busiest sections of the application.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| In Oracle oci_connect() returns a connection identifier needed for most other OCI calls. The optional third parameter can either contain the name of the local Oracle instance or the name of the entry in tnsnames.ora to which you want to connect. If the optional third parameter is not specified, PHP uses the environment variables ORACLE_SID (Oracle instance) or TWO_TASK (tnsnames.ora) to determine which database to connect to.
__________________ With, J. Jeyaseelan Everything Possible |