PDO ayrıntılarına girmeye çalışıyorum. Bu yüzden bu kodlanmış:PDO Filtrelenmemiş sorgular
$cn = getConnection();
// get table sequence
$comando = "call p_generate_seq('bitacora')";
$id = getValue($cn, $comando);
//$comando = 'INSERT INTO dsa_bitacora (id, estado, fch_creacion) VALUES (?, ?, ?)';
$comando = 'INSERT INTO dsa_bitacora (id, estado, fch_creacion) VALUES (:id, :estado, :fch_creacion)';
$parametros = array (
':id'=> (int)$id,
':estado'=>1,
':fch_creacion'=>date('Y-m-d H:i:s')
);
execWithParameters($cn, $comando, $parametros);
benim getValue fonksiyonu çalışıyor ve ben tablo için bir sonraki dizisi olsun. Ben execWithParameters içine almak zaman, ben bu istisna olsun:
PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in D:\Servidor\xampp_1_7_1\htdocs\bitacora\func_db.php on line 77
Ben bağlantı özelliklerini değiştirmeye çalıştı ama çalışmıyor.
Bunlar benim çekirdek db işlevleri şunlardır: Bunun için bir ışık tutabilirfunction getConnection() {
try {
$cn = new PDO("mysql:host=$host;dbname=$bd", $usuario, $clave, array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
));
$cn->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
return $cn;
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
}
function getValue($cn, $comando) {
$resul = $cn->query($comando);
if (!$resul) return null;
while($res = $resul->fetch()) {
$retorno = $res[0][0];
break;
}
return $retorno;
}
function execWithParameters($cn, $comando, $parametros) {
$q = $cn->prepare($comando);
$q->execute($parametros);
if ($q->errorInfo() != null) {
$e = $q->errorInfo();
echo $e[0].':'.$e[1].':'.$e[2];
}
}
biri mi? PD. Lütfen otonomik kimlik yapmamanızı önermeyin, çünkü başka bir sistemden çıkıyorum.
p_generate_seq nedir? SHOW PROSEDÜRÜ p_generate_seq – VolkerK
sorun, orada yok, aynı hata SELECT MAX (id) FROM dsa_bitacora –