Building Update Statment using array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wbryan6
Forum Newbie
Posts: 22
Joined: Sat Feb 04, 2006 12:13 pm

Building Update Statment using array

Post by wbryan6 »

So, I have a rather interesting delimna. I am working on querying information from mssql and saving it into Oracle. Here's the setup I have so far:

Code: Select all

$query_cols = "select column_name from all_tab_columns WHERE table_name = 'TBL_STUDRECORDS'";
$results_cols = oci_parse($link, $query_cols);
$exec_cols = oci_execute($results_cols);
while($line_cols = oci_fetch_row($results_cols))
{
	foreach($line_cols as $value_cols)
	{
		if ($value_cols == 'STREET_1'  || $value_cols == 'STREET_2'  || $value_cols == 'CITY'  || $value_cols == 'ZIPCODE'  || $value_cols == 'PHONE') 
		{
		   $query_Paddress = "SELECT $value_cols FROM Table";
			$results_Paddress = odbc_exec($link_sql, $query_Paddress)
				or die("Cannot execute query.");
			$value_Paddress = odbc_result($results_Paddress, 1);
			echo "$value_cols = '$value_Paddress', ";
		}
	}
}
Incidentally, the SQL and Oracle databases have the same column names intentionally, thus the use of "SELECT $value_cols".

This setup works great, but I now need to turn my echoed value into an Update query. The goal is:

Code: Select all

UPDATE tbl set STREET_1 = 'VALUE1', STREET_2 = VALUE1'...etc.
If I could save the values ($value_cols = '$value_Paddress') into an array, that would be great. What recommendation does everyone have?
Post Reply