Changeset 1593


Ignore:
Timestamp:
2010년 01월 09일 15시 13분 18초 (2 years ago)
Author:
ditto
Message:

relation 모델 추가

Location:
trunk/metabbs
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/metabbs/app/models/board.php

    r1428 r1593  
    2121                $this->comment_table = get_table_name('comment'); 
    2222                $this->category_table = get_table_name('category'); 
     23                $this->category_rel = new OneToManyRelation($this, 'category'); 
    2324        } 
    2425        function get_id() { 
  • trunk/metabbs/app/models/post.php

    r1592 r1593  
    2121                $this->category_table = get_table_name('category'); 
    2222                $this->comment_table = get_table_name('comment'); 
    23                 $this->trackback_table = get_table_name('trackback'); 
    2423                $this->attachment_table = get_table_name('attachment'); 
    2524                $this->tag_table = get_table_name('tag'); 
    2625                $this->tag_post_table = get_table_name('tag_post'); 
     26 
     27                $this->trackback_rel = new OneToManyRelation($this, 'trackback'); 
    2728        } 
    2829        function find($id) { 
     
    121122                $this->db->execute("UPDATE $this->table SET comment_count=$this->comment_count WHERE id=$this->id"); 
    122123        } 
     124 
     125 
     126        // 트랙백 관련 
     127        function get_trackbacks() { 
     128                return $this->trackback_rel->all(); 
     129        } 
     130        function add_trackback($trackback) { 
     131                $this->trackback_rel->add($trackback); 
     132        } 
     133        function get_trackback_count() { 
     134                return $this->trackback_rel->count(); 
     135        } 
     136 
     137 
    123138        function update_attachment_count() { 
    124139                $this->attachment_count = $this->get_attachment_count(); 
    125140                $this->db->execute("UPDATE $this->table SET attachment_count=$this->attachment_count WHERE id=$this->id"); 
    126         } 
    127         function get_trackbacks() { 
    128                 return $this->db->fetchall("SELECT * FROM $this->trackback_table WHERE post_id=$this->id", 'Trackback'); 
    129         } 
    130         function add_trackback($trackback) { 
    131                 $trackback->post_id = $this->id; 
    132                 $trackback->create(); 
    133         } 
    134         function get_trackback_count() { 
    135                 return $this->db->fetchone("SELECT COUNT(*) FROM $this->trackback_table WHERE post_id=$this->id"); 
    136141        } 
    137142        function get_attachments() { 
     
    210215                $this->db->execute("DELETE FROM $this->table WHERE moved_to=$this->id"); 
    211216                $this->db->execute("DELETE FROM $this->comment_table WHERE post_id=$this->id"); 
    212                 $this->db->execute("DELETE FROM $this->trackback_table WHERE post_id=$this->id"); 
     217                $this->trackback_rel->clear(); 
    213218                foreach($this->get_tags() as $tag) 
    214219                                $this->delete_tag_by_name($tag->name); 
     
    245250                        $this->db->execute("DELETE FROM $this->table WHERE id=$_id"); 
    246251                $this->db->execute("UPDATE $this->comment_table SET post_id=$this->id WHERE post_id=$_id"); 
    247                 $this->db->execute("UPDATE $this->trackback_table SET post_id=$this->id WHERE post_id=$_id"); 
     252                $this->trackback_rel->update(array('post_id' => $this->id)); 
    248253                $this->db->execute("UPDATE $this->attachment_table SET post_id=$this->id WHERE post_id=$_id"); 
    249254                $this->metadata->reload(); 
  • trunk/metabbs/core/core.php

    r1568 r1593  
    44requireCore('config'); 
    55$config = new Config(METABBS_DIR . '/metabbs.conf.php'); 
    6 $reserved_containers = array_map(create_function('$s','return trim($s);'), explode(',',$config->get('reserved_containers'))); 
     6$reserved_containers = array_map('trim', explode(',',$config->get('reserved_containers'))); 
    77 
    88$backend = $config->get('backend', 'mysql'); 
     
    1111} 
    1212requireCore('query'); 
     13requireCore('relation'); 
    1314$__cache = new ObjectCache; 
    1415requireModel('metadata'); 
Note: See TracChangeset for help on using the changeset viewer.