PDO Connection problems

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
santa_oscuro
Registered User
Posts: 8
Joined: Tue Jul 04, 2017 10:22 am

PDO Connection problems

Post by santa_oscuro » Sat Aug 11, 2018 8:15 pm

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

User avatar
AmigoJack
Registered User
Posts: 5332
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: PDO Connection problems

Post by AmigoJack » Mon Aug 13, 2018 7:05 am

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.
The worst thing about censorship is ███████████

santa_oscuro
Registered User
Posts: 8
Joined: Tue Jul 04, 2017 10:22 am

Re: PDO Connection problems

Post by santa_oscuro » Fri Aug 17, 2018 11:48 am

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.

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 4 guests