मैं पीडीओ विवरण में शामिल होने की कोशिश कर रहा हूं। तो मैं इस कोडित:पीडीओ अनबफर किए गए प्रश्न
$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);
मेरी getValue समारोह ठीक काम करता है, और मैं मेज के लिए अगले अनुक्रम मिलता है। लेकिन जब मैं execWithParameters में जाता हूं, तो मुझे यह अपवाद मिलता है:
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
मैंने कनेक्शन विशेषताओं को संशोधित करने का प्रयास किया लेकिन यह काम नहीं करता है।
ये मेरी कोर डाटाबेस कार्य हैं:
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];
}
}
किसी ने इस के लिए एक प्रकाश डाला सकता है? पीडी। कृपया autonumeric आईडी करने का सुझाव न दें, क्योंकि मैं किसी अन्य सिस्टम से पोर्टिंग कर रहा हूं।
p_generate_seq की परिभाषा क्या है? दिखाएं प्रक्रिया p_generate_seq – VolkerK
समस्या वहां झूठ नहीं बोलती है, dsa_bitacora –