[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 3 class guestbook_SO 4 { 5 var $db; 6 7 function guestbook_SO() 8 { 9 $this->db = $GLOBALS['egw']->db; 10 $this->db->app = 'sitemgr_module_guestbook'; // as we run as sitemgr ! 11 $this->books_table = 'phpgw_sitemgr_module_guestbook_books'; 12 $this->entries_table = 'phpgw_sitemgr_module_guestbook_entries'; 13 } 14 15 16 function create_book($title) 17 { 18 $this->db->insert($this->books_table,array('book_title' => $title),False,__LINE__,__FILE__); 19 return $this->db->get_last_insert_id($this->books_table,'book_id'); 20 } 21 22 23 function add_entry($name,$comment,$book_id) 24 { 25 $this->db->insert($this->entries_table,array( 26 'name' => $name, 27 'book_id' => $book_id, 28 'comment' => $comment, 29 'timestamp' => time() 30 ),False,__LINE__,__FILE__); 31 } 32 33 function get_entries($book_id) 34 { 35 $this->db->select($this->entries_table,array('name','comment','timestamp'), 36 $this->db->expression($this->table,array('book_id' => $book_id),' ORDER BY timestamp DESC'), 37 __LINE__,__FILE__); 38 39 while($this->db->next_record()) 40 { 41 foreach(array('name','comment','timestamp') as $field) 42 { 43 $entry[$field] = $this->db->f($field); 44 } 45 $result[] = $entry; 46 } 47 return $result; 48 } 49 50 function get_books() 51 { 52 $this->db->select($this->books_table,'*',False,__LINE__,__FILE__); 53 while($this->db->next_record()) 54 { 55 $result[$this->db->f('book_id')] = $this->db->f('book_title'); 56 } 57 return $result; 58 } 59 60 function delete_book($book_id) 61 { 62 $this->db->delete($this->entries_table,array('book_id'=>$book_id),__LINE__,__FILE__); 63 $this->db->delete($this->books_table,array('book_id'=>$book_id),__LINE__,__FILE__); 64 } 65 66 function save_book($book_id,$title) 67 { 68 $this->db->update($this->books_table,array('book_title'=>$title),array('book_id'=>$book_id),__LINE__,__FILE__); 69 } 70 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |