MySQL Forums
Forum List  »  PHP

Re: mysqli class
Posted by: julian haffegee
Date: March 13, 2014 07:24AM

Hi Rick thanks for taking the time to reply

but unfortunately this does not work for me...

the code:

$id = $this->link->insert_id;

will obviously work in the class that does the connecting, disconnecting, and query - but I need to use the insert_id on the page that called the class, not in the class itself.

putting this code into my webpage (not my class) throws an error
(Fatal error: Using $this when not in object context)

###########################################################
Let me sum up again - I am perhaps not making my particular situation clear

I have a class whatever.inc, and a page something.php.

whatever.inc has a 3 functions for connecting (initialize), disconnecting (disconnect) and querying (select) the database

something.php is the main webpage which might query the database using whaever.inc

my code in something.php goes

$q = new whatever();

then I can use this to connect, disconnect and query

$q -> initialize();
$result = $q -> select("SELECT etc etc
$q -> disconnect();

to get the SELECT data in something.php I use

while($a_row = $result->fetch_assoc())

and that works fine.

but If I do an INSERT I want the insert_id

$this->link will only work in whaever.inc
so is it possible to get this value simply in something.php



Edited 1 time(s). Last edit at 03/13/2014 07:25AM by julian haffegee.

Options: ReplyQuote


Subject
Written By
Posted
March 06, 2014 11:25AM
March 08, 2014 01:10PM
March 11, 2014 07:16AM
March 12, 2014 10:34PM
Re: mysqli class
March 13, 2014 07:24AM
March 15, 2014 01:55PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.