Page 1 of 1

PHP Code

Posted: Thu Jan 26, 2006 7:05 pm
by quadoc
I've a quick question. Suppose I've the following code:

select something from table1

value1 = row["col1"]

then I do

Insert into table1 (col1) value (newvalue)

and then I do

value2 = row["col1"]

Is the value2 still equals to value1 or different?

Posted: Thu Jan 26, 2006 7:07 pm
by John Cartwright
should be the same.. but not quite sure what your getting at..

perhaps try it for yourself :wink:

Posted: Thu Jan 26, 2006 8:00 pm
by raghavan20
Jcart wrote:should be the same.. but not quite sure what your getting at..

perhaps try it for yourself :wink:
I think he is just assigning to two different variables and not fetching the data from the DB between assignments.
Now, I am getting a doubt, when a resource like $result is returned, it holds the data is not it...it does not go to database again...is it? :roll:

Posted: Thu Jan 26, 2006 8:48 pm
by John Cartwright
raghavan20 wrote:
Jcart wrote:should be the same.. but not quite sure what your getting at..

perhaps try it for yourself :wink:
I think he is just assigning to two different variables and not fetching the data from the DB between assignments.
Now, I am getting a doubt, when a resource like $result is returned, it holds the data is not it...it does not go to database again...is it? :roll:
Took me about 5 times to read that for some reason..

quadoc: I believe you need to elaborate furthur.

Posted: Fri Jan 27, 2006 3:58 am
by Jenk
$row will contain a copy of the data from the result resource, which will contain a copy from the database, note: copy - not a direct reference. So aslong as you don't update $row after running the INSERT, it will be the same as it was previous to the INSERT.

Posted: Fri Jan 27, 2006 10:48 am
by quadoc
I was trying to see if the value in $row is changing after doing the insert. Thanks guys!