5
I’m getting an error when I use the bindParam from the PDO, code:
Connectionpdo class:
function __construct($dsn, $username = NULL, $password = NULL, $options = NULL) {
parent::__construct($dsn, $username, $password, $options);
$this->LoadDriverMethods();
}
public function insert($table, $data) {
$this->lastSQL = $this->driver->insert($table, $data);
$stmt = $this->prepare($this->lastSQL);
$this->driver->setParams($this->stmt);
return $this->stmt;
}
private function LoadDriverMethods(){
$driver = __DIR__ . DIRECTORY_SEPARATOR . 'drivers' .
DIRECTORY_SEPARATOR . 'sqldriver.' .
strtolower($this->getAttribute(PDO::ATTR_DRIVER_NAME)) . '.php';
if (!is_file($driver))
throw new Exception('Não foi possível carregar os métodos do driver', 1);
require_once $driver;
$this->driver = new SQLDriver();
}
Sqldriver class:
public function setParams(PDOStatement $stmt){
$params = $this->getParams();
if (is_array($params) && !empty($params))
foreach ($params as $param => $value)
$stmt->bindParam($param, $this->prepareParam($value), $this->getParamType($value));
}
Error:
Strict Standards: Only variables should be passed by Reference in Connectionpdo drivers sqldriver.mysql.php
Which refers to the following line in class Sqldriver:
$stmt->bindParam($param, $this->prepareParam($value), $this->getParamType($value));
Thanks, I just noticed that the problem was in the method
bindParam
(the second parameter is a reference), had changed the function$this->prepareParam($value)
by a variable, but bindValue worked well. : D– KaduAmaral
@Kaduamaral, is building a framework?
– rray
Yes rray. Why?
– KaduAmaral
@Kaduamaral organized the code :D
– rray
Is this some ironic joke? : v kkkk... Here the link.
– KaduAmaral
No, the code is legal.
– rray
saved my life :), did not know that term
– Jefferson Mello Olynyki