Tiny Posted August 6, 2018 Report Posted August 6, 2018 Hi all, I am a php (lamer) and about to play a bit with coding, a simple php-file as for now coming that far <?php $servername = "localhost"; $username = "xxx_user"; $password = "99999999"; // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully"; ?> The above connects fine. Needing to read out the corresponding values from /config/blesta.php Anyone can push me the right way? Tiny Quote
Blesta Addons Posted August 6, 2018 Report Posted August 6, 2018 10 hours ago, Tiny said: Hi all, I am a php (lamer) and about to play a bit with coding, a simple php-file as for now coming that far <?php $servername = "localhost"; $username = "xxx_user"; $password = "99999999"; // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully"; ?> The above connects fine. Needing to read out the corresponding values from /config/blesta.php Anyone can push me the right way? Tiny Blesta use PDO , and use Configure class to set/read vars. so first you need to use the Configure class to read the dbinfo so you can include the blesta config and do something like that : $db = Configure::get('Blesta.database_info'); try { $dbh = new PDO('mysql:host=' . $db['host'] .';dbname=' . $db['database'], $db['user'], $db['pass']); } catch (PDOException $e) { print "Erreur !: " . $e->getMessage() . "<br/>"; die(); } Quote
Tiny Posted August 6, 2018 Author Report Posted August 6, 2018 THX, it was/actually planned for the ... see PM Tiny Quote
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.