patrick24601 Posted April 5, 2008 Share Posted April 5, 2008 I have a 'product' object defined. In it there is a property called 'oursql' which I make the PEAR sql connection in. I am going to be calling several methods in this object over and over and I'd like to be able to use the same connection. When I instantiate the product object I create an sql object connection in the __construct() method. product constructor: function __construct() { $oursql = new sqlclass(); } sqlclass in my sql data tier class. It's constructor makes the connection. after I instantiate my product object I make a call to do a query. However that lookup is failiing telling me that $oursql is not defined. $this->oursql->query($query,SQL_INIT); Fatal error: Call to a member function query() on a non-object in ... Can someone please tell me what I am doing wrong ? I'll need to make thousands of calls, and I'd like to be able to use that connection that was established when I created the product object for every query. Thanks, Patrick Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted April 5, 2008 Share Posted April 5, 2008 In the constructor you need to do $this->oursql = new sqlclass(); instead. Quote Link to comment Share on other sites More sharing options...
patrick24601 Posted April 6, 2008 Author Share Posted April 6, 2008 Thanks Daniel. I discovered that last night also before I read your post this morning. The wall is not too damaged from my head beating against it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.