Forum Moderators: coopster
make var:
var $db;
constructor:
function class_pi(){
//constructor
global $database;
//get database
if( defined('_JEXEC') ){
//joomla 1.5
$this->db = JFactory::getDBO();
}else{
//joomla 1.0.x
$this->db = $database;
}
}
use in class:
$this->db->setQuery( "INSERT INTO #__pi......
insert works.
so far so good.
but when this happens:
$id = mysql_insert_id();
echo $id;exit;
it outputs '0'.
This used to work, but not since I call the database in this new way.
anyone?
I get this error when I put anything in between those bracets:
Warning: mysql_insert_id(): supplied argument is not a valid MySQL-Link resource in
that works on Joomla 1.5 as well as on Joomla 1.0.x!
That's realy surprising it works on 1.0.x as well, cos that has no JFactory, so maybe thats some function that already existed. I tried to search for it in the 'development' section of the website, but (as usual) can't find it for Joomla 1.0.x there.
Thank you ever so much, that was the only thing that kept my components code running on both 1.0.x as well as 1.5!
thank you!