MySQL Forums :: PHP :: how to update with array (containing arrays) into table? or inserting? hot to combine with escaping?


Advanced Search

how to update with array (containing arrays) into table? or inserting? hot to combine with escaping?
Posted by: Reg Ister ()
Date: August 08, 2009 04:37PM

Hi!
I have an array with data sets of Nr,Title,Text,Flags in my php-script.
( (1,'oha','oha text',7), (2,'sdf','sdf text',12), (3,'wer','wer text',7), (4,'retg','retg text',0) )
(There is no 'Nr' twice.)

Is there some specific way to update (or insert anew) the data sets in my table from that array? (The table has the correspondening fields Nr,Title,Text,Flags.)

(I can make the sub-array associative if that makes it simpler and doesn't slow it down.)

Or would you suggest just to make a big UPDATE-query-text (or INSERT-query-text) in php first and then send this query to mysql?


Additional Question:
Right now I usually use the following function to escape the data:
function quote_smart($value)
{ if (get_magic_quotes_gpc()) { $value = stripslashes($value);}
if (!is_int($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
Is there any standard and easy way to combine this with the updating (or inserting) from above?


Greetings
Reg

Options: ReplyQuote


Subject Written By Posted
how to update with array (containing arrays) into table? or inserting? hot to combine with escaping? Reg Ister 08/08/2009 04:37PM
THIS SHOULDN'T HAVE BEEN MOVED! Reg Ister 08/08/2009 09:05PM
how to update with array (containing arrays) into table? or inserting? Peter Brawley 08/09/2009 02:55AM
maybe not clearly, but solely Reg Ister 08/09/2009 07:32AM
Re: maybe not clearly, but solely Peter Brawley 08/09/2009 05:52PM
Re: maybe not clearly, but solely Rick James 08/12/2009 10:08AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.