Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not Solved [SOLVED] db->update_query cannot set NULL
#1
Not Solved
I have following code in my test2.php file:
$db->update_query('userfields', array("fid".$mybb->settings['drs_setting_user_fid'] => "NULL"), 'ufid = ' . (int)$user['uid'],"",true);

Let's assume "fid".$mybb->settings['drs_setting_user_fid']" is just fid1.

Here, I set fid1 to "NULL" value, but after I have done above code in PHP, and run "SELECT * FROM mybb_userfields WHERE fid1 IS NOT NULL" in myphpadmin, it still search that fid['drs_setting_user_fid']. It shouldn't even be shown. But it shows like following picture:

   

Blank row between slutty and mcjesus shouldn't even be shown there. I mean, entire row.
All it does is just make fid1 field blank field, but not setting fid1 to NULL to avoid being searched by that select sql command.

How can I make that fid1 actuall NULL that cannot be searched by "SELECT * FROM mybb_userfields WHERE fid1 IS NOT NULL"?
Reply
#2
Not Solved
fid are a not null table in the database, you would need to edit the schema.
[Image: kAhpvOW.png]
Reply
#3
Not Solved
Thank you very much.
How can I edit scheme to be like that?
Reply
#4
Not Solved
Something like the below should do it:

ALTER TABLE mybb_userfields MODIFY fid1 TEXT NULL;
Reply
#5
Not Solved
(01-13-2019, 02:06 PM)online0227 Wrote: Thank you very much.
How can I edit scheme to be like that?

There's no need to change it, it's better if you avoid changes like these (edit standard MyBB database schema). Just set/search for a blank value instead of a NULL value:

UPDATE table SET column = ""
SELECT * FROM table WHERE column = ""

$db->update_query('userfields', array("fid".$mybb->settings['drs_setting_user_fid'] => ""), 'ufid = ' . (int)$user['uid'],"", true);
Reply
#6
Not Solved
(01-13-2019, 03:01 PM)Mipher Wrote:
(01-13-2019, 02:06 PM)online0227 Wrote: Thank you very much.
How can I edit scheme to be like that?

There's no need to change it, it's better if you avoid changes like these (edit standard MyBB database schema). Just set/search for a blank value instead of a NULL value:

UPDATE table SET column = ""
SELECT * FROM table WHERE column = ""

$db->update_query('userfields', array("fid".$mybb->settings['drs_setting_user_fid'] => ""), 'ufid = ' . (int)$user['uid'],"", true);

Thanks very much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)