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

  • Home
  • SEARCH
  • 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 502429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:17:25+00:00 2026-05-13T06:17:25+00:00

I want to create one insert function in php, which I will use to

  • 0

I want to create one insert function in php, which I will use to insert data into database.

Of course all inserts are not the same, some use one table others use other, tables have different column numbers etc. What is the best way to do this ?

I’m currently on the web page for member registration, now I don’t want to allow everyone to register, I want admin to approve which members will get approved and which ones will not, so I set one hidden field to 0 and after approval it becomes one.

CASE: Someone comes to the website and changes input field value to 1 with firebug and submits the registration, automatically gets approved, I didn’t try this I’m just considering the possibility. Now if I put member_active inside insert function then it won’t work for other insert queries with few/less database column rows.

What is the way to do this, is the global/general insert function good idea at all, I pretty much know how to program all of this, but lately I’ve become more careful about data/efficiency and such things that can make your website better/worse so I want a good start. 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-13T06:17:26+00:00Added an answer on May 13, 2026 at 6:17 am

    CodeIgniter also does this, but here it is:

    function Insert($table, $data, $ignore = false)
    {
        $sql = array();
    
        if (is_array($sql) === true)
        {
            $sql['query'] = 'INSERT ';
    
            if ($ignore === true)
            {
                $sql['query'] .= 'IGNORE ';
            }
    
            foreach ($data as $key => $value)
            {
                $data[$key] = Tick($key) . ' = ' . Quote($value);
            }
    
            $sql['query'] .= 'INTO ' . Tick($table) . ' SET ' . implode(', ', $data);
        }
    
        return implode('', $sql);
    }
    

    Obviously, you need to define your own Tick() and Quote() functions to back tick database entities and escape values respectively.

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

Sidebar

Ask A Question

Stats

  • Questions 545k
  • Answers 545k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I suspect your call to Html.ActionLink is picking the wrong… May 17, 2026 at 8:59 am
  • Editorial Team
    Editorial Team added an answer Sorry to say you are not allowed to have a… May 17, 2026 at 8:59 am
  • Editorial Team
    Editorial Team added an answer For info on customising the TFS2010 workflow build templates have… May 17, 2026 at 8:58 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I want to create a CAPTCHA similar to http://www.gigbooks.com/getcaptcha.php this one. But its in
I want to create 4 rectangles stacked to one row. |----|--|------|------------| The width of
I want to create a box like this with title: Can any one please
I want to create a hidden field and create a link in one helper
I want to create a new object using Class::DBI. One of the fields of
Let's say that you want to create a dead simple BlogEditor and, one of
I want to create a function that performs a function passed by parameter on
Because of legacy data which is not available in the database but some external
I am reviewing / redesigning / refactoring a database and want to create a
I want create a drop shadow around the canvas component in flex. Technically speaking

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.