16 {
18
20 SELECT chat_id, room_id
21 FROM chat_room_messages
22 GROUP BY chat_id, room_id
23 ");
24
25 $chat_room_id_comb = array();
26
28 {
29 $chat_room_id_comb[] = array(
$row[
'chat_id'],
$row[
'room_id'] );
30 }
31
32 foreach( $chat_room_id_comb as $combination )
33 {
35 SELECT *
36 FROM chat_room_messages
37 WHERE chat_id = %s
38 AND room_id = %s",
39
40 array( 'integer', 'integer' ),
41 array( $combination[0], $combination[1] )
42 );
43
44 $xml = new SimpleXMLElement('<entries />');
45 $xml->addAttribute('chat_id', $combination[0]);
46 $xml->addAttribute('room_id', $combination[1]);
47
49 {
50 $child = $xml->addChild(
'entry',
$row[
'message']);
51 $child->addAttribute(
'timestamp',
$row[
'commit_timestamp']);
52 }
53
54 $xml->asXML();
55 }
56 }