Page 1 of 1

PDO Connection problems

Posted: Sat Aug 11, 2018 8:15 pm
by santa_oscuro
In principle phpbb works with DBAL but it also works with PDO, so I can add a PDO connection inside index page? supposedly I can, but if I try:

page:

Code: Select all

require_once($phpbb_root_path . 'PDOconexion.' . $phpEx);

$db = new Connect();

$result = $db->query("SELECT d.name FROM Table d") or die("Error.");
inside PDO:

Code: Select all

<?php 
 class Connect extends PDO { 
   private $type = 'mysqli';
   private $host = 'mysql.hostinger.com';
	private $db_name = '';
	private $user = '';
	private $pass = ''; 
   public function __construct() {

      try{
         parent::__construct($this->type.':host='.$this->host.'; dbname='.$this->db_name, $this->user, $this->pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
      }catch(PDOException $e){
         echo 'Error. DDetails: ' . $e->getMessage();
         exit;
      }
   } 
 } 
   
?>
But jumpt this error at time to connect: "could not find driver". I'm using bussiness hostinger (paying)...
I tryed thsi code the code of this page and nothing too: viewtopic.php?f=71&t=2226541

Re: PDO Connection problems

Posted: Mon Aug 13, 2018 7:05 am
by AmigoJack
santa_oscuro wrote:
Sat Aug 11, 2018 8:15 pm

Code: Select all

   private $type = 'mysqli';
This is wrong, it must be mysql. PDO has nothing to do with PHP's native DBMS support. Unless you have a special driver that indeed works for this token.

santa_oscuro wrote:
Sat Aug 11, 2018 8:15 pm
and nothing too
Not even an error message? Because that code looks far better than yours.

So far you "only" have a PHP problem, not a phpBB one.

Re: PDO Connection problems

Posted: Fri Aug 17, 2018 11:48 am
by santa_oscuro
There isn't the problem with mysqli because i wasn't using that. Yeah i saw it that with PDO is not possible and now im using Mysqli that it works.