Jump to content

database(withphp)


Ninjakreborn

Recommended Posts

Is there a way to test what database servers/ or possibilities exist, like for portable code.
Like if it's postgresql, then you can setup that connection, if it's another, then you do another connection.
Is this possible.I wnat to build a function, that when you feed it the variables, the db location, username, password, and database to select.  Then you have an optional parameter of database, but if you don't insert that, it checks to see the first one that is available for testing, sort of like auto-detect, or something.
Link to comment
Share on other sites

You mean a way to query the database using a generic function to try and return the type, e.g. MSSQL, MySQL, Oracle, etc.

Something like (obviously not real code):

[code]<?php
$type = db_type($username, $password, $server);
echo $type;
?>[/code]

If so, then I don't think so, although that would be excellent.  I think you'll need to create a custom function with each of the different connection methods, e.g.

mysql_connect() - MySQL
oci_connect() - Oracle
dba_open() - Berkeley DB
odbc_connect() - Access etc..

And then loop through until you get a successful response.

Regards
Huggie

[color=red][b]P.S[/b][/color] Did that other code I changed for you bring you any joy at all?
Link to comment
Share on other sites

It's possible... If you right a commercial script and you make it compatible with multiple databases but you want to provide an out install script with it or something.  You might want to assume that the user doesn't know, the type, only the details of where it's located.

Regards
Huggie
Link to comment
Share on other sites

The idear is nice but not pradical as all database have slight database code diffrences.

i would erge you to consontrate on one database type.

saying that i have done what your asking but using lots of functions for the database information and it was a right headake.

but good luck businessman nice idear theo. 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.