Monday 05 January 2009 6:24:15 am
Hi everybody ! I have a problem with an extension that I'm writing. The problem is that my fetch is only done when eZ put the page in cache. Once the page is stored, the method from the extension is not called. <b>Function_definition.php</b>
<?php
$FunctionList['forum_visiter'] = array(
'name' => 'forum_visiter',
'operation_types' => array(),
'call_method' => array(
'include_file' => 'extension/damien/modules/damien/forum.php',
'class' => 'Forum',
'method' => 'visiter' ),
'parameter_type' => 'standard',
'parameters' => array(
array( 'name' => 'utilisateur', 'type' => 'string', 'required' => true ),
array( 'name' => 'topic', 'type' => 'string', 'required' => false )
)
);
?>
<b>forum.php</b>
<?php
class Forum {
/**
* Rajoute une entrée dans la base de données pour dire quand un utilisateur a été voir un sujet pour la derniere fois
* \arg $utilisateur ID de l'utilisateur
* \arg $topic ID du noeud correspondant au topic
* \return Rien d'utile : true tout le temps
*/
function visiter($utilisateur, $topic){
echo "<p>Forum::visiter()</p>";
mysql_connect("xxxxxxxxxx", "xxxxxxxxx", "xxxxxxxxx");
mysql_select_db("xxxxxxxxx");
$res = mysql_query("SELECT * FROM visites WHERE id_utilisateur = $utilisateur AND id_topic = $topic");
if(mysql_num_rows($res) > 0)
$sql = "UPDATE visites SET id_utilisateur = $utilisateur, id_topic = $topic, date_visite = ".time();
else
$sql = "INSERT INTO visites (id_utilisateur, id_topic, date_visite) VALUES ($utilisateur, $topic, ".time().")";
mysql_query($sql);
return array("result" => true);
}
}
?>
<b>What does it should do ?</b> When I call the fetch method 'forum_visiter', it should update a database. And it works ! Untill the page is not cached... Could you give me the reason of this strange behaviour (and how to correct it) ? Thank in advance
|