1
johnss
Having problem with xoopsDB->query and SELECT/UNION/SELECT
  • 2004/12/17 1:04

  • johnss

  • Just popping in

  • Posts: 2

  • Since: 2004/10/29


Hi there folks.

I'm working on a module and ran into a problem while using the $xoopsDB->query function.

This statement works:
"SELECT recid,name FROM xoops_newmod_table
UNION ALL
SELECT recid,name FROM xoops_newmod_table2;"

This statement does not work, and returns no error:
"(SELECT recid,name FROM xoops_newmod_table)
UNION ALL
(SELECT recid,name FROM xoops_newmod_table2);"

I've tested the statements through the 'mysql' command line tool and found both to return correct results.

I need the second one so I can put "ORDER BY recid" on the tail end of that SQL statement; "ORDER BY" will only work when the two SELECT statements are encapsulated with paren ().

I was able diagnose this to the point where I can tell you that the central queryF function found inside of class/database/mysqldatabase.php, was not being called for the non-working SQL. It is being called for the functional SQL though. Something is getting in the way.

From that point I am unsure of how "$xoopsDB->query($sql)" function passes it's arguments over to the mysqldatabase.php functions otherwise I'd follow the trail back... I was under the impression that $xoopsDB is just a piece of the databasefactory, but I just can't find where it's getting lost.

In the meantime I can just skip over the use of $xoopsDB and hit the MySQL directly, but I really would prefer to use the XOOPS functions.

Any clues would be appreciated.
Thanks in advance,
John

2
Dave_L
Re: Having problem with xoopsDB->query and SELECT/UNION/SELECT
  • 2004/12/17 3:33

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


If the query does not start with "SELECT", either the query has to be performed as the result of a POST request, or you have to use queryF() instead of query().

3
johnss
Re: Having problem with xoopsDB->query and SELECT/UNION/SELECT
  • 2004/12/17 19:40

  • johnss

  • Just popping in

  • Posts: 2

  • Since: 2004/10/29


I figured something was causing it to be ignored.
Thanks for the quick response and resolution.

-John

Login

Who's Online

460 user(s) are online (82 user(s) are browsing Support Forums)


Members: 0


Guests: 460


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits