Page 1 of 2

How to make Serendipity to work with oracle database?

Posted: Fri Jun 16, 2006 9:23 am
by srinathk11
How to make Serendipity to work with oracle database? Its working fine with MySQL. Is there any method to convert the same work in oracle?

Thanks,
Srinath

Re: How to make Serendipity to work with oracle database?

Posted: Fri Jun 16, 2006 9:40 am
by garvinhicking
Hi!

If you give me access to an oracle DB I could try to create a DB layer for Serendipity.

But sadly oracle has a quite different SQL subset than usual queries that work for mysql/pgsql and sqlite -- so it might be difficult. But since I've never worked with oracle, I could only find out then. :)

Best regards,
Garvin

Posted: Sat Jun 17, 2006 2:10 pm
by falk
Hi,

creating an DB layer for Oracle is not easy because Oracle is a Database not designed for webaccess and ergo it is not easy to implement methods you can use in MySQL etc. (e.g. The Limit must be emulated by a secound or third SQL-Statement. You must store the last SQL-Query and include it in an new SQL-Query that select the Numrow-Count ...). I made some tests to convert all DB-Funktions to access with Oracle. I think it is posible, but with many many hard work and data to store in Sessions. (I am working with PHP and Oracle in my Job.)

S9y-Oracle-Access is one Point on my ToDo-List. I am working on it. but i think there are more interesting things to implement in s9y then support for Oracle.

Thanks!

Posted: Sun Jun 18, 2006 1:13 pm
by srinathk11
Thanks a lot for ur guidance.
My project needs php + oracle. If i face any problems i'll definitely contact you since i find u have some experience in this area.
Thanks.
srinath.

falk wrote:Hi,

creating an DB layer for Oracle is not easy because Oracle is a Database not designed for webaccess and ergo it is not easy to implement methods you can use in MySQL etc. (e.g. The Limit must be emulated by a secound or third SQL-Statement. You must store the last SQL-Query and include it in an new SQL-Query that select the Numrow-Count ...). I made some tests to convert all DB-Funktions to access with Oracle. I think it is posible, but with many many hard work and data to store in Sessions. (I am working with PHP and Oracle in my Job.)

S9y-Oracle-Access is one Point on my ToDo-List. I am working on it. but i think there are more interesting things to implement in s9y then support for Oracle.

Re: Thanks!

Posted: Sun Jun 18, 2006 9:59 pm
by garvinhicking
Hi!

I must really add to Falks statement, that using oracle with a PHP application is in most cases an overkill, since PHP does not have a persistent application state like JSP or others. Connecting to the OracleDB should take longer than the whole PHP application logic. ;-)

Thus I really recommend you to setup a mysql environment, if you plan to use Serendipity (or, for that matter, any other PHP DB-appliocation)

Best regards,
Garvin

Re: Thanks!

Posted: Mon Jun 19, 2006 9:47 am
by srinathk11
HI,

It would be great if u provide some insight about how to do this conversion to oracle/creating a Db layer.
Any links to documents or procedure to do this task will be helpful.

Thanks.
srinath

Help needed

Posted: Mon Jun 19, 2006 9:50 am
by srinathk11
HI,

It would be great if u provide some insight about how to do this conversion to oracle/creating a Db layer.
Any links to documents or procedure to do this task will be helpful.

Thanks.
srinath

falk wrote:Hi,

creating an DB layer for Oracle is not easy because Oracle is a Database not designed for webaccess and ergo it is not easy to implement methods you can use in MySQL etc. (e.g. The Limit must be emulated by a secound or third SQL-Statement. You must store the last SQL-Query and include it in an new SQL-Query that select the Numrow-Count ...). I made some tests to convert all DB-Funktions to access with Oracle. I think it is posible, but with many many hard work and data to store in Sessions. (I am working with PHP and Oracle in my Job.)

S9y-Oracle-Access is one Point on my ToDo-List. I am working on it. but i think there are more interesting things to implement in s9y then support for Oracle.

Re: Thanks!

Posted: Mon Jun 19, 2006 9:56 am
by garvinhicking
Hi!

You basically just need to do this:

- Create a file include/db/oci8.inc.php - you can use the MySQL include file as a starting point.

- You might need to edit the include/db/db.inc.php file to add switch/cases for oracle.

- Inside the include/functions_installer.php you must look for the serendipity_query_default function. There you need to adapt the db'Type' case so something like:

Code: Select all

        case 'dbType' :
            if (extension_loaded('mysqli')) {
                $type = 'mysqli';
            }
            if (extension_loaded('pgsql')) {
                $type = 'postgres';
            }
            if (extension_loaded('mysql')) {
                $type = 'mysql';
            }

            if (extension_loaded('oci8')) {
                $type = 'oci8';
            }

            return $type;
- To make the oracle driver existing as an option in your s9y install you need to edit the include/functions_config.inc.php file, function serendipity_probeInstallation():

Code: Select all

        case 'dbType' :
            $res =  array();
            if (extension_loaded('mysql')) {
                $res['mysql'] = 'MySQL';
            }
            if (extension_loaded('pgsql')) {
                $res['postgres'] = 'PostgreSQL';
            }
            if (extension_loaded('mysqli')) {
                $res['mysqli'] = 'MySQLi';
            }
            if (extension_loaded('sqlite')) {
                $res['sqlite'] = 'SQLite';
            }
            if (extension_loaded('oci8')) {
                $res['sqlite'] = 'Oracle8';
            }
            break;
- Now you need to modify the oracle.inc.php code so that it emits valid SQL for all function calls. As falk pointed out it might very well be that Oracle does not accept some SQL queries from serendipity. All of the s9y SQL was made so that it works on SQLite, MySQL and Postgresql, so hopefully most of it might also work with Oracle. But I have no experience with that.

Best regards,
Garvin

Re: Thanks!

Posted: Mon Jun 19, 2006 10:52 am
by srinathk11
Thanks for the info.
I have some doubt in the creation of below mentioned file:
"Create a file include/db/oci8.inc.php - you can use the MySQL include file as a starting point." what shud be the content of the oci8.inc.php file?shud it be similar to MySql include file.

Thanks.
srinath

garvinhicking wrote:Hi!

You basically just need to do this:

- Create a file include/db/oci8.inc.php - you can use the MySQL include file as a starting point.

- You might need to edit the include/db/db.inc.php file to add switch/cases for oracle.

- Inside the include/functions_installer.php you must look for the serendipity_query_default function. There you need to adapt the db'Type' case so something like:

Code: Select all

        case 'dbType' :
            if (extension_loaded('mysqli')) {
                $type = 'mysqli';
            }
            if (extension_loaded('pgsql')) {
                $type = 'postgres';
            }
            if (extension_loaded('mysql')) {
                $type = 'mysql';
            }

            if (extension_loaded('oci8')) {
                $type = 'oci8';
            }

            return $type;
- To make the oracle driver existing as an option in your s9y install you need to edit the include/functions_config.inc.php file, function serendipity_probeInstallation():

Code: Select all

        case 'dbType' :
            $res =  array();
            if (extension_loaded('mysql')) {
                $res['mysql'] = 'MySQL';
            }
            if (extension_loaded('pgsql')) {
                $res['postgres'] = 'PostgreSQL';
            }
            if (extension_loaded('mysqli')) {
                $res['mysqli'] = 'MySQLi';
            }
            if (extension_loaded('sqlite')) {
                $res['sqlite'] = 'SQLite';
            }
            if (extension_loaded('oci8')) {
                $res['sqlite'] = 'Oracle8';
            }
            break;
- Now you need to modify the oracle.inc.php code so that it emits valid SQL for all function calls. As falk pointed out it might very well be that Oracle does not accept some SQL queries from serendipity. All of the s9y SQL was made so that it works on SQLite, MySQL and Postgresql, so hopefully most of it might also work with Oracle. But I have no experience with that.

Best regards,
Garvin

Re: Thanks!

Posted: Mon Jun 19, 2006 10:58 am
by garvinhicking
Hi!

The oci8.inc.php file needs to contain all the functions that can be found in any of the mysqli.inc.php, mysql.inc.php, sqlite.inc.php or postgresql.inc.php files. The functions then need to do for Oracle, what the others do for the other DB drivers, like creating a valid "LIMIT..." SQL statement.

Best regards,
Garvin

Re: Thanks!

Posted: Mon Jun 19, 2006 11:50 am
by srinathk11
hi garvin,
Thanks for ur valuable contibution.
can u please send me an oci8.inc.php file if u already have one, so that i can use it as a template.
Thanks once again.
srinath.
garvinhicking wrote:Hi!

The oci8.inc.php file needs to contain all the functions that can be found in any of the mysqli.inc.php, mysql.inc.php, sqlite.inc.php or postgresql.inc.php files. The functions then need to do for Oracle, what the others do for the other DB drivers, like creating a valid "LIMIT..." SQL statement.

Best regards,
Garvin

Re: Thanks!

Posted: Mon Jun 19, 2006 12:05 pm
by garvinhicking
Hi!

I have no such file, because as I mentioned I have no OracleDB access. So you should use the mysql class as a template. :)

Best regards,
Garvin

Posted: Mon Jun 19, 2006 12:36 pm
by falk
You can also have a look in the PEAR DB layer classes to be inspiered what to change. I am very interested in your results. After three or four hours i stop the convertation from mysql to oracle.

from where the variables dbuser, dbconn, dbpass defined?

Posted: Mon Jun 19, 2006 12:43 pm
by amita
hi,
i have to do the same thing as srinath.
In mysql.inc.php, mysqli.inc.php, pastgres.inc.php , some variables are defined such as dbconn, dbuser, dbpass, dbpersistent etc. can i know where are those variables defined?

again one thing, for MYSQL ... mysql is used , for Postgre, pg is used. Where is this defined? What we should use for oracle then?

Thanks in advance,
Amita

Re: from where the variables dbuser, dbconn, dbpass defined?

Posted: Mon Jun 19, 2006 1:06 pm
by garvinhicking
Hi!

These variable are used in the files:

$serendipity['dbConn'] - holds the connection id resource, created by the db_connect() function.

$serendipity['production'] - If set to "true", no errors will be emitted. This variable is set to FALSE automatically for all serendipity alpha/beta versions.

$serendipity['dbPersistent'] - If set to TRUE, a DB connection is persistent. This is indicated by the serendipity configuration. MySQL supports persistent connections, I don't know if oracle does. It's a matter of the PHP oci library.

$serendipity['dbHost'], $serendipity['dbUser'], $serendipity['dbPass'], $serendipity['dbName'] holds the credentials required to connect to your database.

$serendipity['dbPrefix'] holds the prefix of serendipity tables (like "serendipity_" by default)

$serendipity['dbCharset'] holds the used charset of the database (only used for mysql currently, would be "utf8" or "iso88591", for example)

Best regards,
Garvin