Reply to thread

Okay, so I am trying a different approach and hoping that it will work, I mean why we try things to learn and have it break lol. So this is my engine so far not sure if it will work; if it's useless coding; or whatnot.

[CODE=php]<?php


namespace Rev;


use PDOStatement;


if(!defined('IN_INDEX')) { die('Sorry, you cannot access this file.'); }


    class engine

    {

        private $initiated;

        private $connected;


        private $connection;


        final public function Initiate()

        {

            global $_CONFIG;

          

            if(!$this->initiated)

            {

                $this->setPDO('connect', PDO::__construct);

                $this->setPDO('query', PDO::query);

                $this->setPDO('num_rows', PDOStatement::rowCount);

                $this->setPDO('fetch_assoc', PDOStatement::fetch);

                $this->setPDO('fetch_array', PDOStatement::fetch);

                $this->setPDO('result', PDOStatement::fetchColumn);

                $this->setPDO('free_result', PDOStatement::closeCursor);

                $this->setPDO('escape_string', PDO::quote);


                $this->initiated = true;


                $this->connect($_CONFIG['mysql']['connection_type']);

            }

        }


        final public function setPDO($key, $value)

        {

          

        }


    }[/CODE]


Not sure what to do for the:  $this->MySQL[$key] = $value;  part I feel like it should be a PDO fetch?



Maybe doing it that way is useless or pointless and I should just do it the correct way for PDO which is

[CODE=php]

$host = 'localhost'; // MySQL host | Example: localhost or 127.0.0.1


$user = 'root'; // MySQL username / loging name | Example: root


$pass = 'Password'; // MySQL Password / leave blank if no PHPMyAdmin password | Example: 'Tester' or (if no password) ''


$db = 'add_database'; // MySQL database / schema


$port = '3306'; // MySQL port


$charset = 'utf8mb4'; //



$dsn = "mysql:host=$host;dbname=$db;charset=$charset;port=$port;";

$options = [

    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,

    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,

    PDO::ATTR_EMULATE_PREPARES   => false,

];

try {

     $pdo = new PDO($dsn, $user, $pass, $options);

} catch (\PDOException $e) {

     throw new \PDOException($e->getMessage(), (int)$e->getCode());

}

[/CODE]


Top