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 7600313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:52:50+00:00 2026-05-30T22:52:50+00:00

In order to not save a user that already exists in the stage, I

  • 0

In order to not save a user that already exists in the stage, I am using the following IF NOT EXISTS statement in my query.

public function save() {
    // new record
    if ( $this->id == null ) {
        $query = "IF NOT EXISTS(SELECT * FROM Table_A WHERE user_id ='{$this->user_id}' and stage_id = '{$this->stage_id}') INSERT INTO Table_A(".
            'id, '.
            'user_id, '.
            'stage_id, '.
            'create_date '.
            ') OUTPUT inserted.id '.
            'VALUES ('.
                'newid(), '. 
                '%s, '.
                '%s, '.  
                'getdate()'.
        ')';

$rs = $this->db->Execute($query);

        if ( $rs->EOF ) {
            return false;
        }

        $rs->Close();
}

..It does the job, but when the user does exist it’s throwing this error:

PHP Fatal error: Uncaught exception ‘com_exception’ with message ‘Source: ADODB.Recordset
Description: Operation is not allowed when the object is closed.’

Wasn’t sure the best way to handle this was, any help is appreciated, thank you!

  • 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-30T22:52:51+00:00Added an answer on May 30, 2026 at 10:52 pm

    Because you close the Recordset by $rs->Close();, the next data fetch from the Recordset is not allowed. You could return $rs;, and after you get your data then close it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Order by descending is not working on LINQ to Entity In the following Query
In my music/rhythm game, I using serialization in order to save user-created simfiles (think
When I try to save a file with the file name that already exists,
I am using Autofac to handle dependency injection in my application. In order not
This is CakePHP 1.3 I have a 5-step order form that stores the new
I try to make it possible to save my listview's new order to cookies
My app will require external storage (SD card) in order to save the user's
I have a base method that I'm writing in order to not repeat the
Problem: I want to list n number of games from each genre (order not
Here's the HTML I'm trying to use: <h1>Order Not Paid<span class=not-paid></span></h1> Of course if

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.