Welcome Guest, Not a member yet? Register   Sign In
unlink photo
#4

[eluser]Narkboy[/eluser]
Ok - I haclked a little because I never get results as objects. Always seems to work faster with arrays unless you need the oop.

So:

Code:
function remove_photo($photo_id) {
    $this->db->where('id_pictures',$photo_id);
    $query = $this->db->get('pictures_table_name');

    if ( $query->num_rows() != 1) {
        // No record with this id:
        return FALSE;
    }

    $result = $query->result_array();
    $result = $result[0]; // Remove the extra level; we don't need it.

    // Now unlink as required:
    unlink( base_url() . $result['thumb'] );
    unlink( base_url() . $result['imagem'] );

    // Now delete from the db:
    $this->db->delete('table_name',array('id_pictures' => $photo_id);

    // Now you're done, either confirm or just trust:
    return TRUE;
}

Is how I'd do it.


Messages In This Thread
unlink photo - by El Forum - 10-21-2010, 07:44 PM
unlink photo - by El Forum - 10-22-2010, 02:27 AM
unlink photo - by El Forum - 10-22-2010, 05:08 AM
unlink photo - by El Forum - 10-22-2010, 05:42 AM
unlink photo - by El Forum - 10-22-2010, 06:00 AM
unlink photo - by El Forum - 10-22-2010, 06:29 AM
unlink photo - by El Forum - 10-22-2010, 07:09 AM
unlink photo - by El Forum - 10-22-2010, 08:59 AM
unlink photo - by El Forum - 10-22-2010, 09:34 AM
unlink photo - by El Forum - 10-22-2010, 09:49 AM
unlink photo - by El Forum - 10-22-2010, 10:13 AM
unlink photo - by El Forum - 10-22-2010, 10:28 AM
unlink photo - by El Forum - 10-22-2010, 10:35 AM
unlink photo - by El Forum - 10-22-2010, 11:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB