views:

29

answers:

2

After a simple query that is successful,

$sql = "SELECT * FROM mytable" ;
$result = mysql_query ( $sql ) ;

is there a way to "drop" a specified column from the $result resource? IOW, the $result consisted previously of 8 fields, but afterwards contains of only 7.

Thanks.

A: 

I think you can't do that after you have commited the query with specified columns. However you can specify this from your query statement as to which columns should be selected.

Sarfraz
Right...I think I may be trying to do something that is not orthodox, but I thought I would check anyway. Thank you for responding.
dave
+1  A: 

What you could do is assign the values from your $result into an array, unset $result to clear up the memory (if it is a large result set), and then unset the specific sub array containing the column data no longer needed.

Thanks, hadn't thought about that! I going to give it a try.
dave
Glad I could help. CakePHP uses a similar system when using their built in find() function.