Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7682623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:36:38+00:00 2026-05-31T18:36:38+00:00

I’m counting the right answers field of a table and saving that calculated value

  • 0

I’m counting the right answers field of a table and saving that calculated value on another table. For this I’m using two queryes, first one is the count query, i retrieve the value using loadResult(). After that i’m updating another table with this value and the date/time. The problem is that in some cases the calculated value is not being saved, only the date/time.

queries look something like this:

        $sql = 'SELECT count(answer)

                FROM #_questionsTable
                WHERE 

                    answer = 1

                    AND

                    testId = '.$examId;

        $db->setQuery($sql);

        $rightAnsCount = $db->loadResult();

        $sql = 'UPDATE #__testsTable

                SET finish = "'.date('Y-m-d H:i:s').'", rightAns='.$rightAnsCount.'

                WHERE testId = '.$examId;

        $db->setQuery($sql);

        $db->Query();

answer = 1 means that the question was answered ok.

I think that when the 2nd query is executed the first one has not finished yet, but everywhere i read says that it waits that the first query is finished to go to the 2nd, and i don’t know how to make the 2nd query wait for the 1st one to end.

Any help will be appreciated. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:36:39+00:00Added an answer on May 31, 2026 at 6:36 pm
    1. a PHP MySQL query is synchronous ie. it completes before returning – Joomla!’s database class doesn’t implement any sort of asynchronous or call-back functionality.

    2. While you are missing a ‘;’ that wouldn’t account for it working some of the time.

    3. How is the rightAns column defined – eg. what happens when your $rightAnsCount is 0

    4. Turn on Joomla!’s debug mode and check the SQL that’s generated in out the profile section, it looks something like this

    eg.

    Profile Information
    
    Application afterLoad: 0.002 seconds, 1.20 MB
    Application afterInitialise: 0.078 seconds, 6.59 MB
    Application afterRoute: 0.079 seconds, 6.70 MB
    Application afterDispatch: 0.213 seconds, 7.87 MB
    Application afterRender: 0.220 seconds, 8.07 MB
    Memory Usage
    
    8511696
    8 queries logged.
    
    SELECT * 
          FROM jos_session 
          WHERE session_id = '5cs53hoh2hqi9ccq69brditmm7'
    DELETE 
          FROM jos_session 
          WHERE ( TIME < '1332089642' )
    etc...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.