[eluser]Unknown[/eluser]
[quote author="Randy Casburn" date="1217736914"]1) How many db connections are you using
2) Are you using this->db->load manually before this code anywhere?
3) Have you verified the resource IDs are consistent?
It's possible there is confusion amongst DB connection IDs. The query would be fine, but the execution of the query could fail because the connection to the resource was 'confused'...not correct, etc.
Just a thought,
Randy[/quote]
I found the problem. It is because a trigger.
CREATE TRIGGER things_ai_trigger AFTER INSERT ON things
FOR EACH ROW BEGIN
DECLARE flag INT;
SELECT t_id INTO flag FROM t_update WHERE t_id = NEW.t_id;
END;
Please see the bold text. if there are more than one row for the same t_id in t_update table, this trigger will generate an error : Result consisted of more than one row. And the insert sql will return with an empty insert id.
And thanks Randy.