RE: [PHP] References

From: Date: Tue, 07 Nov 2000 20:57:24 +0000
Subject: RE: [PHP] References
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-24187@lists.php.net to get a copy of this message
Just had a thought that isn't so off topic. You may want to try the following. 1. Create a class 2. Store your result set in the class 3. Provide a method to access the db 4. provide a method to return the resultset 5. instantiate your class from whereever you desire. So, you'll get something like: class myDataClass{ var $result; function call_db(){ // Db connections etc goes here... $sql = "select * from hugetable"; $this->result = mysql_query($sql); } function get_RecordSet(){ return $this->result; } } // End class myDataClass /// Now in your normal code you can instantiate the object thus: $DbObj = new myDataClass(); $DbObj->call_db(); $ref = $DbObj->get_RecordSet(); This should do you fine as the memory address will exist for as long as the object exists. -----Original Message----- From: Vidyut Luther [mailto:vluther@phpcult.com] Sent: 07 November 2000 19:44 To: php-general@lists.php.net Subject: [PHP] References I was wondering why this is not possible. function get_a_lot_of_data() { $sql = "select * from hugetable"; $result = mysql_query($sql); return &result; } I have to do this all the time, $ref = &$result; return $ref; why do i have to create the reference first, and then pass it ? i have no formal education in programming.. so any of you computer sci majors wanna clear this up for me ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#24187) next »