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
Blesta Addons Posted August 6, 2018 Report Posted August 6, 2018 On 8/6/2018 at 9:11 AM, 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 Expand 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(); }
Tiny Posted August 6, 2018 Author Report Posted August 6, 2018 THX, it was/actually planned for the ... see PM Tiny
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now