crabfinger Posted February 4, 2010 Share Posted February 4, 2010 Alright I'm designing a database library so that when the user installs my application to their server it will allow you to select the database type out of a list of available database engines. Also allowing you to chose which server/database engine/database/table/format for every piece of data taken from the database, making it extremely easy to install it on a system which uses a series of database engines/databases for data carried across multiple types of applications without needing to modify files. My current issue is generating a list of possible database engines and checking to see which ones are installed on the system and enabled through php. Any help would be much appreciated, thank-you in advance. Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/ Share on other sites More sharing options...
crabfinger Posted February 5, 2010 Author Share Posted February 5, 2010 Bump... Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1007283 Share on other sites More sharing options...
Mchl Posted February 5, 2010 Share Posted February 5, 2010 Just about only general thing you can check is what PHP extensions are installed. Other than that you don't really have means of checking what is available (other than trying to connect using default settings). Perhaps you cold also grab a process list from system and see what's there. Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1007285 Share on other sites More sharing options...
ignace Posted February 5, 2010 Share Posted February 5, 2010 You can try this: define('MYSQL_ENABLED', function_exists('mysql_connect') ? true : false); define('SQLITE_ENABLED', function_exists('sqlite_open') ? true : false); //.. Then when the user selects a database you can verify that it is available. Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1007483 Share on other sites More sharing options...
crabfinger Posted February 5, 2010 Author Share Posted February 5, 2010 Thanks ignace, I didn't even think of doing that. Now i feel pretty stupid. Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1007529 Share on other sites More sharing options...
ignace Posted February 5, 2010 Share Posted February 5, 2010 Now i feel pretty stupid. That is generally called the learning process If you knew all you probably wouldn't be here instead making billion dollar applications ultra-optimized to execute in pico-seconds Hell you would probably take a vacation on Pluto or some other Galaxy far, far away Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1007649 Share on other sites More sharing options...
Mchl Posted February 5, 2010 Share Posted February 5, 2010 Still, it doesn't tell you anything more than what PHP extensions are enabled. Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1007655 Share on other sites More sharing options...
crabfinger Posted February 6, 2010 Author Share Posted February 6, 2010 Yes but its not like I can get data from a database if the extension is not installed in php. Why would I want to know if it is installed on the system if it can't be used. Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1007981 Share on other sites More sharing options...
Mchl Posted February 6, 2010 Share Posted February 6, 2010 My point is, you have no reliable way of checking if/what database system is available. I thought that's what you were after. Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1007988 Share on other sites More sharing options...
ignace Posted February 6, 2010 Share Posted February 6, 2010 Well I figured that if the user selected for example mysql then a logical step would be to try to connect using his provided input. However if the extension isn't loaded/installed then those functions aren't available unless I'm wrong at this and they are even if the extension is loaded or not but then what is their default implementation? I don't fully understand what you mean by: "no reliable way of checking if/what database system is available" Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1008008 Share on other sites More sharing options...
Mchl Posted February 6, 2010 Share Posted February 6, 2010 From original post My current issue is generating a list of possible database engines and checking to see which ones are installed on the system and enabled through php. On another note: Even if say ext/mysql is not available, there still may be ext/mysqli or PDO_mysql. Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1008010 Share on other sites More sharing options...
ignace Posted February 6, 2010 Share Posted February 6, 2010 On another note: Even if say ext/mysql is not available, there still may be ext/mysqli or PDO_mysql. Ok yeah but you can solve that as: define('MYSQL_ENABLED', function_exists('mysql_connect')); define('MYSQLi_ENABLED', function_exists('mysqli_connect')); Doesn't PDO use the mysql or mysqli extension? Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1008016 Share on other sites More sharing options...
wildteen88 Posted February 6, 2010 Share Posted February 6, 2010 Doesn't PDO use the mysql or mysqli extension? No. It uses its own function library. Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1008018 Share on other sites More sharing options...
ignace Posted February 6, 2010 Share Posted February 6, 2010 Doesn't PDO use the mysql or mysqli extension? No. It uses its own function library. Well this is all new to me till now I never have had this problem. I do find it interesting as this means that I would be able to leave the mysql and mysqli extension disabled and just include the pdo extension and still be able to connect to any (supported) database. I now understand what Mchl meant as I can check for mysql or mysqli but the problem rises when it comes to PDO as it may be enabled but provides no means to verify a mysql server is present besides instantiating PDO with the MySQL driver and check for an error but then again is it because the user mistyped the password or the lack of the mysql presence. Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1008023 Share on other sites More sharing options...
Mchl Posted February 6, 2010 Share Posted February 6, 2010 but then again is it because the user mistyped the password or the lack of the mysql presence. The error message would be different for each of those. Quote Link to comment https://forums.phpfreaks.com/topic/190969-detecting-possible-database-engines-compatible-with-php-installed-on-the-compute/#findComment-1008039 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.