1
jwells
xoopsDB help needed please
  • 2004/12/30 19:08

  • jwells

  • Just popping in

  • Posts: 5

  • Since: 2004/10/17


Greetings,

I am writing my first package for xoops, or I should say re-writing it as I originally wrote a small tool using native PEAR:B calls to read and write data to my DB. Now I am in the process of converting it to use xoopsDB calls instead. While the select statements are working correctly, the update statements are failing miserably.

I have the following SQL update statement
<code>
$sql = sprintf("UPDATE envStats SET envStatus=2,envChangedBy='%s' WHERE UID='%s'", $thisUser, $_GET['envUp']);
$xoopsDB->query($sql);
</code>
Once, and once only have I even seen this get to the MySQL server. Looking at various code throughout the XOOPS core, I see similar statements being used fairly often, and they appear to be working correctly, however, this one does not seem to get to the MySQL server.

To help troubleshoot this issue, I added;
<code>
print($sql ."<br>\n");
</code>

It printed out;
<code>
UPDATE EnvStats SET envStatus=2,envChangedBy='jwells' WHERE UID='5'
</code>
So at this point, I know it is creating the correct MySQL update command. I turned on SQL logging and watched it while I ran this script and saw multiple select statements, by XOOPS and my script and one update statement called by XOOPS to update xoops_session.

So my question is, how can I force XOOPS to send the update statement to MySQL?

2
ackbarr
Re: xoopsDB help needed please

I'll go out on a limb here. The page that contains the update query was a GET request not a form submission. XOOPS's db object prevents the execution of UPDATE, INSERT and DELETE queries from get pages. The work-around is to use $xoopsDB->queryf() which bypasses the protection.

3
jwells
Re: xoopsDB help needed please
  • 2004/12/30 19:42

  • jwells

  • Just popping in

  • Posts: 5

  • Since: 2004/10/17


BINGO!!!!

Yes, the page is being called via GET. I changed the update statements and they all fire correctly. Thank you so much.

4
Mithrandir
Re: xoopsDB help needed please

Or use a POST request and $xoopsDB->query()...

Login

Who's Online

234 user(s) are online (158 user(s) are browsing Support Forums)


Members: 0


Guests: 234


more...

Donat-O-Meter

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

Latest GitHub Commits