MyBB Community Forums

Full Version: SQL & Mybb (Thinking) issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I'm sure there is a simple way to do this, but I cannot wrap my head around it.

So look at the code (before I explain):

// Grab Group ID (From user)
$p_GroupID = $db_Data["usergroup"];

// Select From DB
$db_HQuery = $db->simple_select("test_options", "*", "pgroup='$p_GroupID'");
$db_HData = $db->fetch_array($db_HQuery);

^^ That works fine.

This works fine if there is just 1 GroupID in pgroup.
However a better way would be if I can save multiple group id's into the pgroup column (example: '4,5,6') like that, but how would one grab it from DB and compare it?

Thanks!
should work by using arrays & explode function ! this reply might help
(2016-05-11, 05:13 PM).m. Wrote: [ -> ]should work by using arrays & explode function ! this reply might help

Thanks, I understand that part but my question was how I can retrieve the row from DB?
I only need to retrieve the one(s) that contain my group id.
how do those groups entered into database ? in general we use plugin settings.
please see how settings are added .. plugins basics guidance

eg.
$pgroups = explode(',', $mybb->settings['plugin_pgroups']);
(2016-05-11, 05:57 PM).m. Wrote: [ -> ]how do those groups entered into database ? in general we use plugin settings.
please see how settings are added .. plugins basics guidance

eg.
$pgroups = explode(',', $mybb->settings['plugin_pgroups']);

Those groups are entered in database (as described above) like this '4,5,6' the numbers being the group id.

I need a way to read the row and the only reference point being the group id.
You could try and use LIKE condition.

http://www.techonthenet.com/sql/like.php
You can grab the data in the column explode it and search the array for the information you need by using the in_array function.