mysqli and pdo support in hook files
Posted: 2015-06-03 08:02
I understand that Appgini 5.40 supports mysqli and pdo connections but I am having trouble updating an old mysql connection that I'd like to replace in my hooks files.
This mysql connection and query IS working in my __global.php hook file:
but if I try to update the query to a mysqli connection with:
I receive the error: Fatal error: Class 'mysqli' not found in /folder/hooks/__global.php
Can anyone help me with I'm dong wrong please? Am I missing something?
Even better still, I'd like to update to a PDO connection. Is that possible with Appgini 5.40 and assuming it is,what's required to get the connection working? Thanks.
This mysql connection and query IS working in my __global.php hook file:
Code: Select all
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("databasename") or die(mysql_error());
mysql_query( "INSERT INTO etc, etc, etc...") or die(mysql_error());
Code: Select all
$db = new mysqli('localhost', 'username', 'password', 'databasename');
if($db->connect_errno > 0){
die('Unable to connect to database [' . $db->connect_error . ']');
}
mysqli_query($db, "INSERT INTO etc, ec, etc...") or die('Unable to connect to database [' . $db->connect_error . ']');
Can anyone help me with I'm dong wrong please? Am I missing something?
Even better still, I'd like to update to a PDO connection. Is that possible with Appgini 5.40 and assuming it is,what's required to get the connection working? Thanks.