1 Replies - 4440 Views - Last Post: 15 August 2012 - 05:03 PM Rate Topic: -----

#1 mulapalliprasad   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-August 12

MYSQL Database Abstraction Layer , how to get mysql_insert_id ?

Posted 14 August 2012 - 11:28 AM

in the DB class
* @name MYSQL Database Abstraction Layer
* @author Joey Adams
* @see http://bin.joeyadams.net/mysql_ab_pro/
* @version 4.0
* @uses
* Use this Abstraction layer to keep your business logic seperate.

unable to get last inserted id. I have added the following but failed.

i called as below

$result = $this->mysqlDAOFactoryInstance->getConnection()->query($q);
$result = $this->mysqlDAOFactoryInstance->getConnection()->getLastInsertedId();



 
public function getLastInsertedId()
        {
            return mysql_insert_id();
        }




what could be missing ?

I have also tried the following but failed to get last inserted id
$result = $this->mysqlDAOFactoryInstance->getConnection()->dbqueryRetInsertId($q);




 public function dbqueryRetInsertId($query){
		//$return_style = $this->_getReturnStyle($return_style);
		
			if(!$resultSet = mysql_query($query,$this->_link)){
				$this->error(mysql_error());
			}
		//}
		return( mysql_insert_id() );
	}


This post has been edited by JackOfAllTrades: 14 August 2012 - 11:47 AM


Is This A Good Question/Topic? 0
  • +

Replies To: MYSQL Database Abstraction Layer , how to get mysql_insert_id ?

#2 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: MYSQL Database Abstraction Layer , how to get mysql_insert_id ?

Posted 15 August 2012 - 05:03 PM

Is the query executing successfully? Does the data get inserted into the table?

The mysql_insert_id function does optionally take a MySQL connection resource as it's only parameter, so based on what you posted you should be passing it the $this->_link reference. (Same goes for the mysql_error call.)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1