SQLSTATE[HY000]: General error: 1364 Field 'group_id' doesn't have a default value:
) VALUES ('', 5, 0, 'toggle', 'pulse_artist', 'Pulse Artist', '', 'n', 'n', 'n', 'YToxOntzOjE5OiJmaWVsZF9kZWZhdWx0X3ZhbHVlIjtzOjE6IjAiO30=')
In the 4.0.0 update it should have modified any existing group_id and site_id fields to allow null:
ee()->smartforge->modify_column('channel_fields', array( 'site_id' => array( 'type' => 'int', 'unsigned' => TRUE, 'null' => TRUE, ), 'group_id' => array( 'type' => 'int', 'unsigned' => TRUE, 'null' => TRUE, ), ));
It looks to me like that didn’t happen, and that’s the problem. It’s easy enough to fix, but I don’t like the fact it happened. And maybe something else didn’t get updated as well. So- we need to keep an eye out.
But other than that- switch those both to allow null. If you do it via query, be sure to backup the table before hand and then
ALTER TABLE exp_channel_fields MODIFY group_id INT UNSIGNED
Thanks! That worked. But one follow up question:
Where does that data live in the db? I’m using Query module for this as it’s querying a large list. Would it not be in the same row as the rest of the channel entry? In my Field Manager, my new Toggle field is listed with an ID of #363, but the columns in the channel entries I’ve already been querying stop at 355.
I’ve been successfully using a SQL query for a few years that retrieves (for example): Name, Organization, Country
and now I’m trying to query: Name, Organization, Country, this new Toggle Field
does that live elsewhere and I’m going to have to do some sort of JOIN?
Thanks Robin. I’m afraid my SQL chops aren’t all that. Was channel entry querying efficiency improved with this database change? I was using the Query module because using the Channel Entries tag was requiring a lot of memory. Is it worth trying with Channel Entries again or should I suck it up and figure out the proper SQL query? (i realize this is a hard question to answer)
It just depends on what you’re doing- 600 is a lot. It’s not really the query that’s going to eat up overhead, it’s parsing it. The regular channel tag is parsing a lot.
But- here’s a cheat if you’re not good with queries. Go put the channel entry tag on an empty template- nothing else on it. Turn debugging on in ‘Settings- Debug and Output’. Then look at your template while logged in. You can view all of the queries. Grab the one pulling back your exp_channel_data_field_x and just simplify the stew out of it.
I think it’s just a left join to pull in an extra table. So look at the query and pull out the part you need and add it to what you’re already doing.
If you get stuck, just yell and I’ll take a look.
It’s pretty big. I feel like I could figure it out from there but I don’t understand all of the integers at the end. would i have to manually add a new integer to the query each time I created a new entry? (let’s see if this form will let me post this query in here):
SELECT t.entry_id, t.channel_id, t.forum_topic_id, t.author_id, t.ip_address, t.title, t.url_title, t.status, t.view_count_one, t.view_count_two, t.view_count_three, t.view_count_four, t.allow_comments, t.comment_expiration_date, t.sticky, t.entry_date, t.year, t.month, t.day, t.edit_date, t.expiration_date, t.recent_comment_date, t.comment_total, t.site_id as entry_site_id,
w.channel_title, w.channel_name, w.channel_url, w.comment_url, w.comment_moderate, w.channel_html_formatting, w.channel_allow_img_urls, w.channel_auto_link_urls, w.comment_system_enabled,
m.username, m.email, m.screen_name, m.signature, m.sig_img_filename, m.sig_img_width, m.sig_img_height, m.avatar_filename, m.avatar_width, m.avatar_height, m.photo_filename, m.photo_width, m.photo_height, m.group_id, m.member_id,
wd.*, exp_channel_data_field_363.field_id_363, exp_channel_data_field_363.field_ft_363 FROM exp_channel_titles AS t
LEFT JOIN exp_channels AS w ON t.channel_id = w.channel_id
LEFT JOIN exp_channel_data AS wd ON t.entry_id = wd.entry_id
So the integers are the entry id numbers. Right before that query was another query where it got the entry ids- then it sticks them in there. You probably only want to do one query. So basically the ‘where’ part of the first query- or since you’re already doing it, the where part of you existing query.
Then something like:
SELECT t.entry_id, t.title, wd.field_id_x AS something_cool, exp_channel_data_field_363.field_id_363 AS some_other_cool_field FROM exp_channel_titles AS t LEFT JOIN exp_channel_data AS wd ON t.entry_id = wd.entry_id LEFT JOIN exp_channel_data_field_363 ON t.entry_id = exp_channel_data_field_363.entry_id WHERE some stuff
So you’re pulling in 3 tables- the exp_channel_titles table (t), the exp_channel_data table (wd) and that one field table exp_channel_data_field_336.
I put some aliases in there- that’s the AS some_other_cool_field- because it’s just easier to keep up with, especially with the query form.
You must need to fill in the ‘where’ bits and add any other fields you want to the select bit.
If anything doesn’t work, post me back what you’ve got so far. But I suspect you’re really close.