cformsII Support Forum
Current User: Guest *Frequently Asked Questions*
Search 
Search Forums:


 




Help with query for cformsdata

Add a New Topic Reply to Post
Post

cb - Guest

5:38 pm - May 14, 2008

1

Please replace the ??? with your data!

  • Your URL: http://???
  • The browser used: Firefox
  • cforms version: 8.4.2
  • Your Wordpress version: 2.5.1

[desc]:

Hello,

I have a form with (including 'page' and 'fieldset') 15 field_names. When I try to query the db to display the data in a table, I recently started getting this error:

"Can\'t use players: The SELECT would examine more than MAX_JOIN_SIZE
rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET
SQL_MAX_JOIN_SIZE=# if the SELECT is okay"

My query string (simplified to save space):

$querystr = "
SELECT FN.sub_id, SEL.`sel`, FN.`First Name` , LN.`Last Name` , DOB.`dob`
FROM ( SELECT sub_id, field_val AS 'First Name'
FROM $wpdb->cformsdata
WHERE `field_name` = 'First Name'
)FN, ( SELECT sub_id, field_val AS 'Last Name'
FROM $wpdb->cformsdata
WHERE `field_name` = 'Last Name'
)LN, ( SELECT sub_id, field_val AS `Team`
FROM $wpdb->cformsdata
WHERE `field_name` = 'Team'
)TEAM, ( SELECT sub_id, field_val AS `dob`
FROM $wpdb->cformsdata
WHERE `field_name` = 'DOB'
)DOB
WHERE FN.sub_id = LN.sub_id
AND LN.sub_id = TEAM.sub_id
AND TEAM.sub_id = DOB.sub_id
AND TEAM.Team = 'Boys'
ORDER BY LN.`Last Name`
";

Can someone suggest a simpler approach to extracting the information for presentation on page?

Thanks for any ideas.

Oliver - Admin

10:02 pm - May 14, 2008

posts 3909

2

WOW. This query certainly looks a bit over the top. Quite frankly I don't even understand what it is doing ;-)

I recommend you look at the cforms source code (cforms-database.php, js/include/lib_database_*) and extract the code you need to read all submissions/data and afterwards present it any way you want...

cb - Guest

2:51 am - May 15, 2008

3

Basically, it makes a table of sub_id, and first name, a table of sub_id and last name, a table if sub_id and xxx.... then selects the values for all the sub_ids where field_name = "Team" and field_val = "Boys". Since I am not proficient at SQL, I'm sure there is a less expensive, more elegant way to do this.

Thanks for the pointers to the cforms source, that's where I was going to look next.

cb


Oliver - Admin

7:19 am - May 15, 2008

posts 3909

4

I see. Generally, I would rather do this kind of 'arranging of data' in an Array outside of SQL, unless the size of the data is so huge it would throw your PHP memory consumption over board. Then I would create something like 'views' within your SQL database tables that run in parallel to the cforms tables and essentially do what your SQL statements does, but on a server level.

Reply to Post


Reply to Topic: Help with query for cformsdata
PLEASE READ THE FAQs FIRST! THANK YOU.

NOTE: New Posts are subject to administrator approval before being displayed

Guest Name (Required):

Guest EMail (Required):

Topic Reply:

Save New PostSmileysOptions

Guest URL (required)

Math Required!
What is the sum of:
2 + 8
   

 
Confused Cool Cry Embarassed Frown Kiss Laugh Smile Surprised Wink Yell

Search