Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Line 64 - parent::read('app_users', null, null, "WHERE {$this->places}", null, $this->parses);
- Read.php
- <?php
- namespace app\Controllers\Dns
- {
- use PDO;
- class Read extends Conn
- {
- private $select;
- private $places;
- private $callback;
- /** @var PDOStatement */
- private $read;
- public function read($table, $fields = '*', $inners = null, $clause = null, $others_clause = null, $parse = null)
- {
- $this->parses($parse);
- $this->select = "SELECT {$fields} FROM {$table} {$inners} {$clause} {$others_clause}";
- $this->execute();
- }
- public function result()
- {
- return $this->result;
- }
- public function rowcount()
- {
- return $this->Read->rowCount();
- }
- public function columnName($columnName)
- {
- if($this->rowcount > 0):
- foreach($this->result as $this->callback):
- return $this->callback->$columnName;
- endforeach;
- endif;
- }
- private function parses($parse)
- {
- if(!empty($parse)):
- $this->places = $parse;
- parse_str($parse, $this->places);
- endif;
- }
- private function connect()
- {
- $this->Read = parent::conn()->prepare($this->select);
- $this->Read->setFetchMode(PDO::FETCH_OBJ);
- }
- private function syntax()
- {
- if($this->places):
- foreach($this->places as $index => $value):
- if($index == 'limit' || $index == 'offset'):
- $value = (int) $value;
- endif;
- $this->Read->bindValue(":{$index}", $value, (is_int($value) ? PDO::PARAM_INT : PDO::PARAM_STR));
- endforeach;
- endif;
- }
- protected function Execute() {
- $this->connect();
- try{
- $this->syntax();
- $this->Read->execute();
- $this->Result = $this->Read->fetchAll();
- } catch (PDOException $e) {
- // Manager errors here
- }
- }
- }
- }
- Conn.php
- <?php
- namespace app\Controllers\Dns
- {
- use PDO;
- /**
- * Class Conn
- * @package app\Controller
- */
- class Conn
- {
- /** @var string */
- private $mysql_host = 'localhost';
- /** @var string */
- private $mysql_user = 'root';
- /** @var string */
- private $mysql_password = '';
- /** @var string */
- private $mysql_database = 'user';
- /** @var null */
- private $connect = null;
- /** @ar array */
- private $options;
- /** @var string */
- private $dns;
- private function connect()
- {
- try {
- line 36 - if(!$this->connect):
- $this->options = [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8'];
- $this->dns = 'mysql:host=' . $this->mysql_host . ';dbname=' . $this->mysql_database;
- $this->connect = new PDO($this->dns, $this->mysql_user, $this->mysql_password, $this->options);
- endif;
- }catch (\PDOException $e){
- PHPErro($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine());
- die();
- }
- self::$connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- return self::$connect;
- }
- /**
- * @return object
- */
- public static function conn(){
- return self::connect();
- }
- }
- }
- Erro gerado
- <b>Fatal error</b>: Uncaught Error: Using $this when not in object context in Conn.php:36
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement