no mysql_insert_id() after $this->db->setQuery( "INSERT
Posted: Thu Mar 13, 2008 2:59 pm
To make my components work in both Joomla 1.5 and older versions I made in the constructor of my class the $db into a var. All works except for when I make an insert, because I can't get the id any more.
make the var:
constructor:
use in class:
so far so good.
but when this happens:
it outputs '0'.
This used to work, but not since I call the database in this new way.
anyone?
make the var:
Code: Select all
var $db;
Code: Select all
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;
}
}
Code: Select all
$this->db->setQuery( "INSERT INTO #__pi......
but when this happens:
Code: Select all
$id = mysql_insert_id();
echo $id;exit;
This used to work, but not since I call the database in this new way.
anyone?