Announcement

Collapse
No announcement yet.

Checking a SQL Query Result For Emptiness

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Checking a SQL Query Result For Emptiness

    Basically how do you do it?

    SELECT * FROM "tablename" WHERE userid=bbuserinfo['userid'];

    If there is no row with that userid in it then

    INSERT INTO "tablename" (userid,realpost,spampost) VALUES (x,y,z);

    But if there is a row then

    UPDATE "tablename" (userid,realpost,spampost) VALUES (x,a,b)


    How do i check the result for emptiness?

  • #2
    Check the value of the return from your first query...

    Not sure where this is going but it already sounds like it is better suited for www.vbulletin.org than it is for here.
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API - Full / Mobile
    Vote for your favorite feature requests and the bugs you want to see fixed.

    Comment


    • #3
      oh how did i know that was gonna happen, should i just head over to vbulletin.org now

      would this work

      PHP Code:
      $sqlquery=$DB_Site->query("Insert Query Here")
       
      if (
      $sqlquery == '')
      {
      INSERT xxxxxxxxxxxxxxxx
      }
      else
      {
      update XXXXXXXXXXXXXXX

      Or would i have to use strlen?

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...
      X