本文整理汇总了PHP中Conversation::ajouterMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Conversation::ajouterMessage方法的具体用法?PHP Conversation::ajouterMessage怎么用?PHP Conversation::ajouterMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conversation
的用法示例。
在下文中一共展示了Conversation::ajouterMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_messages
function get_messages()
{
//creation d'un Resultat
//variables globales
global $id, $table_general, $table_conversations, $table_messages;
//recherche des personnes connectees
$listing = new Resultat();
//delai (= maintenant - 1 minute)
$delai = date('Y-m-d H:i:s', mktime(date('H'), date('i') - 1, date('s'), date('m'), date('d'), date('Y')));
//personnes connectees
$sql = "SELECT identifiant FROM " . $table_general . " WHERE date_dernier_signal > '" . $delai . "';";
$resultat = mysql_query($sql);
while ($present = mysql_fetch_array($resultat)) {
if ($present['identifiant'] != $id) {
//creation d'un binome
$binome = new Binome($present['identifiant']);
//recherche d'une conversation courante
$sql = "SELECT * FROM " . $table_conversations . " WHERE user1 = '" . $binome->nom1 . "' AND user2 = '" . $binome->nom2 . "' AND session_1 = '" . $binome->session1 . "' AND session_2 = '" . $binome->session2 . "';";
$conversation = mysql_query($sql);
if (!$conversation || mysql_num_rows($conversation) == 0) {
//on ajoute dans la liste sans conversation
$listing->ajouter_ami(new Ami($present['identifiant'], null));
} else {
//on va chercher des messages
$sql = "SELECT * FROM " . $table_messages . " WHERE conversation = " . mysql_result($conversation, 0, 'id_conversation') . " ;";
$messages = mysql_query($sql);
$maConv = new Conversation();
while ($message = mysql_fetch_array($messages)) {
//ajout de messages
$maConv->ajouterMessage(new Message($message['expediteur'], $message['destinataire'], $message['date'], $message['texte']));
}
$listing->ajouter_ami(new Ami($present['identifiant'], $maConv));
}
}
}
// parsing en XML //////////////////
echo "\n<connectes>";
echo "\n\t<derniere_MAJ>" . $listing->derniere_MAJ . "</derniere_MAJ>";
foreach ($listing->amis as $personne) {
echo "\n\t<ami>";
echo "\n\t\t<nom>" . $personne->nom . "</nom>";
if ($personne->conversation != null) {
echo "\n\t\t<conversation>";
echo "\n\t\t\t<date>" . $personne->conversation->date . "</date>";
foreach ($personne->conversation->messages as $mess) {
echo "\n\t\t\t<message>";
echo "\n\t\t\t\t<de>" . $mess->expediteur . "</de>";
echo "\n\t\t\t\t<vers>" . $mess->destinataire . "</vers>";
echo "\n\t\t\t\t<texte>" . $mess->texte . "</texte>";
echo "\n\t\t\t</message>";
}
echo "\n\t\t</conversation>";
}
echo "\n\t</ami>";
}
echo "\n</connectes>";
}