Hallo,
ich habe in einer MVC ein class MySQL implementiert , es sieht nähmlich so aus :
ich habe mir danach eine Klasse Login gebaut die dann diese Klasse benutzt :
die befehle prepare funktioniert soweit ( ich habe es mit var_dump überprüft) , aber bindParam funktioniert nicht !!
Folgende Fehlermeldung bekomme ich : Catchable fatal error: Object of class stdClass could not be converted to string wo bindParam vorkommt!!
ich habe in einer MVC ein class MySQL implementiert , es sieht nähmlich so aus :
PHP-Code:
<?php
class MySQL extends PDO
{
private $_result = NULL;
private $_link = NULL;
private static $_instance = NULL;
private $_config = array();
public static function getInstance(array $config = array())
{
if (self::$_instance === NULL)
{
self::$_instance = new self($config);
}
return self::$_instance;
}
public function __construct(array $config)
{
if (count($config) < 3)
{
throw new Exception('Invalid number of connection parameters');
}
self::$_instance = $this;
$this->_config = $config;
list($dsn, $user, $password) = $this->_config;
parent::__construct($dsn, $user, $password); $this->setAttribute(PDO::ATTR_STATEMENT_CLASS,array('MyPDOStatement', array($this)));
$this->setAttribute(self::ATTR_ERRMODE, self::ERRMODE_EXCEPTION);
}
class MyPDOStatement extends PDOStatement {
protected $connection;
protected function __construct(PDO $connection)
{
$this->connection = $connection;
}
}
}
PHP-Code:
class login {
private $id = NULL;
private $loginname = NULL;
private $passwort = NULL;
private $email = NULL;
private $session = NULL;
private $dbconnection = NULL;
private $config = array(SQL_DSN, SQL_USERNAME, SQL_PASSWORD);
public function __construct($sessionid)
{
$this->dbconnection = MySQL::getInstance($this->config);
$this->sessions = $sessionid;
}
public function logged_in(){
$_query = 'SELECT * FROM users WHERE session = :session';
$query = $this->dbconnection->prepare($_query);
$query->bindParam(':session', $this->session);
$query->execute();
return ($this->dbconnection->countRows('users') !== 1) ? false :true;
}
Folgende Fehlermeldung bekomme ich : Catchable fatal error: Object of class stdClass could not be converted to string wo bindParam vorkommt!!
Kommentar