To retrieve data from a specific custom_field in a channel entry I used to do the following:

$data = ee()->db->select('field_id_2')
        'entry_id' => $entry_id

$field_value = $data->row('field_id_2');

How would I do that now ? Is there somewhere I can I find examples for getting and setting data in channel entries using the ChannelEntry model ?

(examples in the docs are for members and templates and I don't get how it relates to entries)

1 Answer 1


The documentation of the EE models is pretty sparse right now - hopefully over time that will improve.

To do what you describe this kind of approach will work - there maybe better ways (hopefully if so someone who knows will post another answer)...

This sets up a variable that links to a single entry in the EE database, from where you can either get or set specific fields etc. You can use any field in the filter - as before the core EE fields are accessed by name (e.g. entry_id, url_title) and custom variables by variable ID (e.g. field_id_65). The first() gets a single value, leave this off and you get an object with all matching entries.

$entry = ee('Model')->get('ChannelEntry')->filter('url_title', $your_url_title)
$entry_id_of_found = $entry->entry_id; // get a value 
$entry->$field_id_65 = "some text about cats liking chicken"; // set a value
$entry->save(); // write changes back to EE database


  • doc is pretty sparse, yes... I found out that you can also quickly access to a field value in it's specific table like so : ee()->db->select('field_id_7')->from('exp_channel_data_field_7')
    – laurent
    Commented Sep 6, 2019 at 12:50
  • 1
    using the model looks really cool, but var_dumping $entry is pretty scary. I think we need some proper docs
    – laurent
    Commented Sep 6, 2019 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.