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 »

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: 6109
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: PDO Connection problems

Post 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 pmand 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 problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
santa_oscuro
Registered User
Posts: 8
Joined: Tue Jul 04, 2017 10:22 am

Re: PDO Connection problems

Post 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.
Post Reply

Return to “phpBB Custom Coding”