Comment puis-je activer cette fonction? La dernière requête n'est pas exécutée .. J'ai beaucoup cherché des requêtes dans une boucle (foreach, for, while) mais rien .. J'essaie de stocker des sessions.requête multiple + requête unique
private function gc($expire)
{
$gcq = "SELECT `path`, `last`, LENGTH(`path`) FROM `sessions` WHERE LENGTH(`path`) > 0 AND DATE_ADD(`last`, INTERVAL ".(int) $expire." SECOND) < NOW();";
$gcq .= "DELETE FROM `sessions` WHERE DATE_ADD(`last`, INTERVAL ".(int) $expire." SECOND) < NOW()";
if($this->dbh->multi_query($gcq))
{
$arr_gc = null;
$count = 0;
do {
if($result = $this->dbh->store_result())
{
while($row = $result->fetch_assoc())
{
$arr_gc[$count] = array($row['path'], $row['last']);
$count++;
}
$result->free();
}
if($this->dbh->more_results())
{
$garbage = null;
}
}
while($this->dbh->next_result());
}
// no problems up here..
// problems from here to end....
$alfa = count($arr_gc);
if($alfa > 0)
{
$count = 0;
while($count < $alfa)
{
$this->dbh->query("INSERT INTO `store_sess` SET `xpath` = '".$this->dbh->real_escape_string($arr_gc[$count][0])."', in = '".$this->dbh->real_escape_string($arr_gc[$count][1])."', out = '0000-00-00 00:00:00'");
$count++;
}
}
return $this->dbh->affected_rows;
}
EDIT: structure de table store_sess:
id int (autoincrement)
xpath longtext
in datetime (tried also with varchar)
out varchar
Vous êtes certain que 'alfa' $> 0, non? – Matt
oui maintenant je débogue avec alfa = 2 – lollo