Jump to content


Photo

database(withphp)


  • Please log in to reply
8 replies to this topic

#1 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 12 October 2006 - 04:54 AM

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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 12 October 2006 - 10:27 AM

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):

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

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

P.S Did that other code I changed for you bring you any joy at all?
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 12 October 2006 - 10:54 AM

I assume this is an intellectual exercise not a real problem, since it would be unlikely you would be writing code to access a database without knowing what database you were trying to access.
Legend has it that reading the manual never killed anyone.
My site

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 12 October 2006 - 11:01 AM

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
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 12 October 2006 - 12:06 PM

I am about to start a huge project, with a friend, he is wanting it to be heavily portable, so I was just going through available options I might go with pear:db

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 12 October 2006 - 12:37 PM

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. 
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 12 October 2006 - 01:27 PM

That's why i said Pear:db, it allows you to support many databases, with just one set of functions.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#8 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 12 October 2006 - 01:48 PM

You might also look into using pdo. In my experience it has been great, of course your locked into php5 > then though.

#9 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 12 October 2006 - 02:11 PM

Thanks, it gives me something new to play with.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users