Ben PDO ayrıntıları girmek için çalışıyorum. Yani bu kodlu:
$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 ama, ben bu istisna olsun:
PDOException: sqlstate [HY000]: Genel hata: diğer tamponsuz sorgular aktif iken 2014 sorguları yürütmek olamaz. PDOStatement :: fetchAll () kullanmayı düşünün. Kod sadece hiç mysql karşı çalıştırmak için gidiyor ise Alternatif olarak, PDO :: MYSQL_ATTR_USE_BUFFERED_QUERY niteliğini ayarlayarak sorgu arabelleğe etkinleştirebilirsiniz. D: satır 77 \ Servidor \ xampp_1_7_1 \ htdocs \ bitacora \ func_db.php
Ben bağlantı özelliklerini değiştirmeye çalıştı ama o çalışmıyor.
Bunlar benim ana db işlevleri şunlardır:
function 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];
}
}
Bunun için bir ışık tutabilecek birileri? PD. I başka bir sistemden taşıma am nedeni, autonumeric id yapıyor öneririz etmeyiniz.