TAILIEUCHUNG - Tạo mạng xã hội với PHP - part 34

Groups If we are setting the first post, our controllers can access this post object by calling the getFirstPost method, and then calling the appropriate public methods on the post object. /** * Return the object for the first post, for setting fields * @return Object */ public function getFirstPost() { return $this-post; } We have a number of setter methods, as standard. /** * Set the group this topic should be part of * @param int $group * @return void */ public function setGroup( $group ) { $this-group = $group; } /** * Set the creator of the topic * @param int $creator. | Groups If we are setting the first post our controllers can access this post object by calling the getFirstPost method and then calling the appropriate public methods on the post object. Return the object for the first post for setting fields return Object public function getFirstPost return this- post We have a number of setter methods as standard. Set the group this topic should be part of @param int group return void public function setGroup group this- group group Set the creator of the topic param int creator return void public function setCreator creator this- creator creator Set the name of the topic param String name return void public function setName name this- name name ------------------------------------ 312 ----------------------------------- Download from Chapter 10 We have our save method which if appropriate also saves the post once the topic has been created. Save the topic into the database return void public function save if this- id 0 update array update creator this- creator update name this- name update group this- group this- registry- getObject db - updateRecords topics update ID . this- id else insert array insert creator this- creator insert name this- name insert group this- group this- registry- getObject db - insertRecords topics insert this- id this- registry- getObject db - lastInsertID if this- includeFirstPost true this- post- setTopic this- id this- post- save Next we have a getter for the name property and also a toTags method which is now almost a standard for most of our models. Get the name of the topic public function getName return this- name ------------------------------------ 313 -------------------------------- Download from Groups Convert the topic data to template tags @param String prefix prefix for the template tags return void public function toTags prefix foreach this as field data if is_object data is_array data this- registry- getObject template - getPage - addTag prefix. field .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.