Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Is it feasible to code RevCMS style to be PDO?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="FirefighterKyle" data-source="post: 472972" data-attributes="member: 22469"><p>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.</p><p>[CODE=php]<?php</p><p></p><p>namespace Rev;</p><p></p><p>use PDOStatement;</p><p></p><p>if(!defined('IN_INDEX')) { die('Sorry, you cannot access this file.'); }</p><p></p><p> class engine</p><p> {</p><p> private $initiated;</p><p> private $connected;</p><p></p><p> private $connection;</p><p></p><p> final public function Initiate()</p><p> {</p><p> global $_CONFIG;</p><p> </p><p> if(!$this->initiated)</p><p> {</p><p> $this->setPDO('connect', PDO::__construct);</p><p> $this->setPDO('query', PDO::query);</p><p> $this->setPDO('num_rows', PDOStatement::rowCount);</p><p> $this->setPDO('fetch_assoc', PDOStatement::fetch);</p><p> $this->setPDO('fetch_array', PDOStatement::fetch);</p><p> $this->setPDO('result', PDOStatement::fetchColumn);</p><p> $this->setPDO('free_result', PDOStatement::closeCursor);</p><p> $this->setPDO('escape_string', PDO::quote);</p><p></p><p> $this->initiated = true;</p><p></p><p> $this->connect($_CONFIG['mysql']['connection_type']);</p><p> }</p><p> }</p><p></p><p> final public function setPDO($key, $value)</p><p> {</p><p> </p><p> }</p><p></p><p> }[/CODE]</p><p></p><p>Not sure what to do for the: $this->MySQL[$key] = $value; part I feel like it should be a PDO fetch?</p><p></p><p></p><p>Maybe doing it that way is useless or pointless and I should just do it the correct way for PDO which is </p><p>[CODE=php]</p><p>$host = 'localhost'; // MySQL host | Example: localhost or 127.0.0.1</p><p></p><p>$user = 'root'; // MySQL username / loging name | Example: root</p><p></p><p>$pass = 'Password'; // MySQL Password / leave blank if no PHPMyAdmin password | Example: 'Tester' or (if no password) ''</p><p></p><p>$db = 'add_database'; // MySQL database / schema</p><p></p><p>$port = '3306'; // MySQL port</p><p></p><p>$charset = 'utf8mb4'; //</p><p></p><p></p><p>$dsn = "mysql:host=$host;dbname=$db;charset=$charset;port=$port;";</p><p>$options = [</p><p> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,</p><p> PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,</p><p> PDO::ATTR_EMULATE_PREPARES => false,</p><p>];</p><p>try {</p><p> $pdo = new PDO($dsn, $user, $pass, $options);</p><p>} catch (\PDOException $e) {</p><p> throw new \PDOException($e->getMessage(), (int)$e->getCode());</p><p>}</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="FirefighterKyle, post: 472972, member: 22469"] 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] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Is it feasible to code RevCMS style to be PDO?
Top