Witam,
Potrzebuje pomocy w obejściu problemu jaki pojawił mi się podczas używania mysqli.
Otóż piszę funkcję rekurencyjną i wyciągam pewne dane z bazy, jednak po wejściu w rekurencje mysqli zwraca mi Commands out of sync; you can't run this command now
Z tego co się orientuję to przyczyną jest (chociaż nie używam MYSQLI_USE_RESULT):
/* If we have to retrieve large amount of data we use MYSQLI_USE_RESULT */
if ($result = $mysqli->query("SELECT * FROM City", MYSQLI_USE_RESULT)) {
/* Note, that we can't execute any functions which interact with the
server until result set was closed. All calls will return an
'out of sync' error */
if (!$mysqli->query("SET @a:='this will not work'")) {
printf("Error: %s\n", $mysqli->error);
}
$result->close();
}
$mysqli->close();
Moja struktura wygląda mniej więcej tak:
function lista($id = 0){
global $mysqli;
$array = array();
if($result = $mysqli->query("call lista($id)")){
while($obj = $result->fetch_object()){
$array[$obj->id]['nazwa'] = $obj->nazwa;
$array[$obj->id]['tablica'] = $this->lista($obj->id);
}
$result->free();
return $array;
}
else
return NULL;
}
nie mogę przed wejściem w rekurencje zamknąć $result bo stracę część danych, po wyskoczeniu z rekurencji pętla musi wykonać pozostałe rezultaty
macie jakieś pomysły??