PHP-PDO-MySQL-Class
PHP-PDO-MySQL-Class copied to clipboard
Using define to input database credentials and also making them public
<?php
define('DBHost', '127.0.0.1');
define('DBName', 'Database');
define('DBUser', 'root');
define('DBPassword', '');
require(dirname(__FILE__)."/src/PDO.class.php");
$DB = new Db(DBHost, DBName, DBUser, DBPassword);
?>
Why can't use ini file that puts credentials to main db function and link with main db php class, which won't require parameters to be required everytime. Just execute db() and go.
I'm worried about bad coding habits will lead to some security issues.
@sachya but you could place the above codes for db connection in a separate file and call just include it on pages you want to execute database functions?