RE: query help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The most performant methods are to use well parameterized stored procedure or a prepared parameterized statement.

: Ashay

-----Original Message-----
From: Niel Archer [mailto:not@xxxxxxxxxx] 
Sent: Wednesday, November 17, 2010 6:30 AM
To: php-db@xxxxxxxxxxxxx
Subject: Re:  query help

> Hello PHP Gurus,
> 
> I need your help on an insert query.
> 
> I wanted to know if there is way to insert an array of values into a 
> DB. An eg would explain this better :
> 
> If I have 2 tables in a DB, 1) users has 3 columns 2) hobbies = 5 
> columns
> 
> I was thinking of having a single function which will perform the 
> insert on any  insert which happens on the entire website.
> 
> Eg : This function can be called with 2 parameters, the first 
> parameter the table name, and the second parameter is an array of 
> values which will be inserted into the table.
> eg : Users has these columns [1]ID [2] Name [3]Location so the 
> function call would be something like *
> insert_into_tbale(users,array[user_values])*
> **
> Does this make sense ? Is this a good method to follow ?
> 
> Thanks in advance !
> 
> Vinay Kannan.

You don't give any info about the database engine, but assuming you're using MySQL  take a look at http://dev.mysql.com/doc/refman/5.0/en/insert.html
Specifically you can use your idea to build an INSERT/VALUE version of the syntax

INSERT INTO table (col1, col2, .colN.)  VALUES (col1Value1, col2value1, colNvalue1),  (col1Value2, col2value2, colNvalue2),  ...


--
Niel Archer
niel.archer (at) blueyonder.co.uk


--
PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux