PHP stores the reference of the variable to use it. When you call $qry->bindParam(1, $obj->qux, PDO::PARAM_INT)
, the reference stored is the reference of the member of the instanciated class.
When you change the member $obj->qux
, the reference is still the same than the one stored in your $obj
. However, if you reinstanciate $obj
to a new class, then every references are changed, but your old object is still in memory ! So when you assign a new value to the new $obj->qux
, it is not the same variable used, so running $qry->execute
will use the old value.
I hope I've been clear enough.