Welcome Guest, Not a member yet? Register   Sign In
Passing blank array to db->insert function
#1

[eluser]Computerzworld[/eluser]
Hello. I am trying to pass blank array to the db->insert function because I want last insert id. But I am getting an error like "You must use the "set" method to update an entry." How can I solve it? please help me. Thanks in advance.
#2

[eluser]webthink[/eluser]
Quote:I am trying to pass blank array to the db->insert function because I want last insert id.
This sentence tells me that it may be worth rethinking your application structure. Can you explain more about why you'd need to do this?

I'm not all that surprised to learn that CI won't let you insert with an empty array. If you're really insistent on doing this you could just add a column called create_time (int) to your table and pass it php's time()
#3

[eluser]gtech[/eluser]
$ret = $this->db->insert_id();

the above code will return the last insert id after an insert.
#4

[eluser]nicholas.byfleet[/eluser]
I'm having this issue as well.
#5

[eluser]jedd[/eluser]
What issue?

(I really can't see an issue above - other than bad design / confused intent.)
#6

[eluser]alboyd[/eluser]
Yeh what is going on here?

I'm guessing you are checking LAST_INSERT_ID() at a time after the insert db session has been closed down? Maybe? I don't really get what your problem is though or exactly the circumstances in which you are trying to get this last insert id...
Quote:For LAST_INSERT_ID(), the most recently generated ID is maintained in the server on a per-connection basis.
MySQL Reference
#7

[eluser]alboyd[/eluser]
[quote author="Computerzworld" date="1209112394"]Hello. I am trying to pass blank array to the db->insert function because I want last insert id. But I am getting an error like "You must use the "set" method to update an entry." How can I solve it? please help me. Thanks in advance.[/quote]

Reading your OP more carefully - apart from, as everyone has mentioned, your approach being possibly flawed, it sounds like your query is invalid. Perhaps you forgot the SET in your query?
#8

[eluser]Rahul gamit[/eluser]
i am using storedprocedure for inserting the data into the database, so how can i retrieve last inserted id ?




Theme © iAndrew 2016 - Forum software by © MyBB