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 Link to comment https://forums.phpfreaks.com/topic/99738-solved-trying-to-use-the-same-sql-connection/ 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. Link to comment https://forums.phpfreaks.com/topic/99738-solved-trying-to-use-the-same-sql-connection/#findComment-510206 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. Link to comment https://forums.phpfreaks.com/topic/99738-solved-trying-to-use-the-same-sql-connection/#findComment-510678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.