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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:23:28+00:00 2026-06-17T08:23:28+00:00

I am developing an application in PHP for which I need to implement a

  • 0

I am developing an application in PHP for which I need to implement a big file handler.
Reading and writing the file is not a problem, but checking the content of the file is a problem.

I built a recursive function which checks whether or not a variable is already used in the same document.

private function val_id($id){
    if(!isset($this->id)){
            $this->id = array();
        }
    if(in_array($id, $this->id)){
        return $this->val_id($id+1);
    }else{
        $this->id[] = $id;
        return $id;
    }
}

When in_array($id,$this->id) returns FALSE, the $id will be added to $this->id (array which contains all used ids) and returns a valid id.

When this returns TRUE, it returns the same function with parameter $id+1

Since we are talking about over 300000 records a time, PHP won’t not to be able to store such big arrays. It seems to quit writing lines in the documents I generate when this array gets too big. But I don’t receive any error messages like that.

Since the generated documents are SQL files with multiple rows INSERT another solution could be to check if the id already exists in the database. Can MySQL catch these exceptions and try these entries again with adding 1 to id? How?

How do you think I need to solve this problem?

Kind regards,

Wouter

  • 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-06-17T08:23:29+00:00Added an answer on June 17, 2026 at 8:23 am

    Use INSERT IGNORE to disable duplicate key check in mysql and remove your key check in php. Your statement could look like this.

    INSERT IGNORE INTO tbl_name SET key1 = 1, col1 = 'value1'
    

    If you want to add 1 to the id always you could use ON DUPLICATE KEY to increment your key by one:

    INSERT INTO table (a,b,c) VALUES (1,2,3)
        ON DUPLICATE KEY UPDATE c=c+1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing application in PHP which takes video file. I am giving serverside
I am developing a PHP/MySQL application which entails processing of CSV files but the
I'm developing application which need access to user's facebook account. It is working, but
I'm developing a web application and I'm using a file called functions.php in which
i am developing a php application which run on offline mode mean not connect
I'm developing a PHP application which uses Twig (but that's unimportant) as the view
We're developing an application based on neo4j and php with about 200k nodes, which
I am developing a PHP application which needs a regular expression to replace the
I am developing php application in which i am querying database and the generated
I am developing a Facebook Application in which I need to view the user_work_history

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.