Adding an array in a SQL query
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #1
Adding an array in a SQL query
I am trying to make a plugin, and have hit a problem. The purpose of the plugin is to show a list on the usercp for the Xthreads files users have added on leefish (my site)

I have this query which works fine - it shows the list of uploaded files only on the userCP of the person who has uploaded them

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function downloadsonucp_run()
{
	global $db, $mybb, $templates, $theme, $lang, $my_last_threads;
	
	$lang->load("downloadsonucp");

	}
	
	if($mybb->settings['downloadsonucp_showlastthreads'] == "1")
	{
		$mdxquery = $db->query("
			SELECT t.*, t.subject AS threadsubject, u.username, u.usergroup, u.displaygroup, f.*, i.*, i.name AS iconname,
			t.dateline AS threaddate, f.name AS forumname
			FROM ".TABLE_PREFIX."threads t
			LEFT JOIN ".TABLE_PREFIX."xtattachments a ON (a.tid=t.tid)
			LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=t.fid)
			LEFT JOIN ".TABLE_PREFIX."icons i ON (i.iid=t.icon)
			LEFT JOIN ".TABLE_PREFIX."users u ON (t.lastposter=u.username)
			WHERE t.uid = '".$mybb->user['uid']."'
			AND t.visible = '1'
			AND a.field = 'fupload'
			GROUP BY t.tid
			ORDER BY threaddate DESC
		");


but I need to add more variables to the list after the where - like this

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function downloadsonucp_run()
{
	global $db, $mybb, $templates, $theme, $lang, $my_last_threads;
	
	$lang->load("downloadsonucp");

	}
	
	if($mybb->settings['downloadsonucp_showlastthreads'] == "1")
	{
		$mdxquery = $db->query("
			SELECT t.*, t.subject AS threadsubject, u.username, u.usergroup, u.displaygroup, f.*, i.*, i.name AS iconname,
			t.dateline AS threaddate, f.name AS forumname
			FROM ".TABLE_PREFIX."threads t
			LEFT JOIN ".TABLE_PREFIX."xtattachments a ON (a.tid=t.tid)
			LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=t.fid)
			LEFT JOIN ".TABLE_PREFIX."icons i ON (i.iid=t.icon)
			LEFT JOIN ".TABLE_PREFIX."users u ON (t.lastposter=u.username)
			WHERE t.uid = '".$mybb->user['uid']."'
			AND t.visible = '1'
			AND a.field = 'fupload'
			OR a.field = 'fupload2'
			OR a.field = 'fupload3'
			GROUP BY t.tid
			ORDER BY threaddate DESC
		");


But as soon as I add that OR in the query then the list becomes visible on ALL UCPs..... so I think I may need an array in there, but I don't know how to do that. Can anyone help?



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 11-02-2010 04:58 AM by leefish.)
11-02-2010 04:58 AM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Adding an array in a SQL query - leefish - 11-02-2010 04:58 AM
RE: Adding an array in a SQL query - RateU - 11-02-2010, 05:42 AM
RE: Adding an array in a SQL query - RateU - 11-02-2010, 07:02 AM
RE: Adding an array in a SQL query - techu - 11-02-2010, 12:16 PM
RE: Adding an array in a SQL query - RateU - 11-03-2010, 07:31 AM

 Standard Tools
Forum Jump: