Does PHP offer a way to insert into MySQL in this format?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Claus Mygind
    Contributor
    • Mar 2008
    • 571

    Does PHP offer a way to insert into MySQL in this format?

    MySQL has two formats for the insert syntax.

    I see the first format is accepted in PHP
    Code:
    INSERT INTO Persons (FirstName, LastName, Age)
    VALUES ('Peter', 'Griffin', '35')
    But I have grown accustom to the other form of name/value pairs as it is easier to see the connection between column and value.
    Code:
    INSERT INTO Persons 
    SET FirstName='Peter', LastName='Griffin', Age=35)
    Can this be done in PHP?

    I am new and I am using PHP v5.3.3 with MySQL v5.0
  • Mayur2007
    New Member
    • Aug 2007
    • 67

    #2
    Yes you can use any of the above to insert data in mysql.

    Regards,
    Mayur Bhayani

    Comment

    Working...