//mdl_album.php
<?php class Mdl_album extends RZ_Model { var $table = 'yh_albums'; var $user_id = 0; var $album_id = 0; function Mdl_album () { parent::Model(); } function add ( $data ) { if ( empty( $this->user_id ) ) { return false; } if ( array_key_exists( 'album_id', $data ) ) { unset( $data ); } $data['created_by'] = $this->user_id; $data['createtime'] = time(); $this->db->insert( $this->table, $data ); $this->album_id = $this->db->insert_id(); return $this->album_id; } function del () { if ( empty( $this->user_id ) or empty( $this->album_id ) ) { return false; } $this->db->where( 'album_id', $this->album_id ); $this->db->where( 'created_by', $this->user_id ); return $this->db->delete( $this->table ); } function update ( $data ) { if ( empty( $this->user_id ) or empty( $this->album_id ) ) { return false; } if ( array_key_exists( 'album_id', $data ) ) { unset( $data['album_id'] ); } $this->db->where( 'album_id', $this->album_id ); $this->db->where( 'created_by', $this->user_id ); //echo '<pre>';print_r($data);echo '</pre>';exit; //echo 1;exit; return $this->db->update( $this->table, $data ); } function set_cover ( $image ) { if ( empty( $this->user_id ) or empty( $this->album_id ) ) { return false; } $this->db->where( 'album_id', $this->album_id ); $this->db->where( 'created_by', $this->user_id ); return $this->db->update( $this->table, array( 'cover_image' => $image ) ); } }
//mdl_image.php
<?php class Mdl_image extends RZ_Model { var $table = 'yh_images'; var $user_id = 0; var $image_id = 0; var $album_id = 0; function Mdl_image () { parent::Model(); } function add ( &$data ) { if ( empty( $this->user_id ) ) { return false; } if ( array_key_exists( 'image_id', $data ) ) { unset( $data ); } $data['created_by'] = $this->user_id; $data['createtime'] = time(); $this->db->insert( $this->table, $data ); $this->image_id = $this->db->insert_id(); return $this->image_id; } function del () { if ( empty( $this->user_id ) or empty( $this->image_id ) ) { return false; } $this->db->where( 'image_id', $this->image_id ); $this->db->where( 'created_by', $this->user_id ); return $this->db->delete( $this->table ); } function after_album_del () { if ( empty( $this->user_id ) or empty( $this->album_id ) ) { return false; } $this->db->where( 'album_id', $this->album_id ); $this->db->where( 'created_by', $this->user_id ); return $this->db->delete( $this->table ); } }
