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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:10:25+00:00 2026-05-14T19:10:25+00:00

I was going through this article today. http://vinothbabu.com/2010/05/08/update-and-insert-differences-in-syntax-is-an-inconvenience/ I was not able to understand

  • 0

I was going through this article today.

http://vinothbabu.com/2010/05/08/update-and-insert-differences-in-syntax-is-an-inconvenience/

I was not able to understand this part of the code written by the author.

    list($sets,$cols,$values)=escape_arr($sets);

    $insert_sql=”INSERT INTO `avatars` “.implode(’,',$cols).” 
    VALUES(”.implode(’,',$values).”)”;

    $update_sql=”UPDATE `avatars` SET “.implode(’,',$sets).”
    WHERE userid=$userid LIMIT 1″;

and finally the conclusion part of the article.

  • 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-14T19:10:25+00:00Added an answer on May 14, 2026 at 7:10 pm

    The PHP implode turns the array of column names into a comma separated string. It does the same for the values in the INSERT statement.

    $sets starts off as an associative array of column name / value pairs. This statement:

    list($sets, $cols, $values) = escape_arr($sets);
    

    reassigns the $sets variable to be a regular array containing strings like “column_name = ‘value'”. It does this with the helper function escape_arr in the article, which returns 3 arrays. Check the documentation for list if you’re unsure what it does.

    Then it uses the implode function again to build one big comma separated string of the $sets array. So effectively, it builds both INSERT and UPDATE statements given an associative array containing column names as keys, and their values as well… values.

    Was that the question? You can insert some var_dump statements in the code to follow what it’s doing at every step.

    Edit: sorry for the messy explanation, but I gotta run for now 🙂

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

Sidebar

Related Questions

I was going through this article : http://www.ajaxline.com/32-tips-to-speed-up-your-mysql-queries at point#4 , it states :
I've been going through this excellent article http://msdn.microsoft.com/en-us/library/ms972976.aspx that says ViewState is not responsible
I was going through this article http://dev.opera.com/articles/view/objects-in-javascript/ where I read 'this' keyword doesn’t always
I have been reviewing model binding with collections, specifically going through this article http://weblogs.asp.net/nmarun/archive/2010/03/13/asp-net-mvc-2-model-binding-for-a-collection.aspx
I have been looking through this fantastic article: http://blogs.zynaptiq.com/bernsee/pitch-shifting-using-the-ft/ While being fantastic, it is
I was going through Jeffrey Palermo's book and came across this syntax. private void
I was going through an article today when it mentioned the following: We've found
In C following this article ( http://blogs.msdn.com/oldnewthing/archive/2006/12/21/1340571.aspx ), we have succesfully been able to
Going through this article class ThreadTest { static void Main() { Thread t =
I was going through this article to understand more about Java Serialization process. When

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.