Questions tagged [insert-id]

47 questions
0
votes
1 answer

I need help for persisting into oracle database

There is a problem about generating id while persisting into database. I added the following code to my jpa entity file, however I'm getting 0 for personid. @Id @Column(unique=true, nullable=false, precision=10,…
coderxyz24
  • 11
  • 2
  • 11
0
votes
1 answer

How can I use insert_id from one method in model in another method in the same model

I have a problem with insert_id. I'm using CodeIgniter. I have a method in which I insert some values and in it I return $insert_id=$this->db->insert_id(); return $insert_id;` I want to use this value in another method in the same model. I tried…
ivva
  • 2,819
  • 9
  • 31
  • 64
0
votes
0 answers

How to use the same insert_id() in CodeIgniter from one function to another function

I have a function in my model in CodeIgniter where I insert in Database and I return $result=$this->db->insert_id(); return $result;. I have another function in this model where I insert other values in another table and I need to insert in…
ci_lover
  • 710
  • 1
  • 14
  • 38
0
votes
1 answer

Mysqli con function

why insert_id return 0 thanks This is my connect function : function baglan(){ $mysqli = mysqli_connect('localhost', 'aa', 'aa', 'aa')or die("aa"); $mysqli->set_charset("utf8"); if (mysqli_connect_errno()) { echo "Failed to connect…
peace
  • 21
  • 7
0
votes
1 answer

MYSQL duplicates when using ->insert_id

I was happy when I got this to work but it submits the order twice unless I comment out the last two lines. Is there a better way to write it so that I don't get duplicates? $sql = "INSERT INTO orders (weight, shipper, shipacct) VALUES ('$weight',…
0
votes
1 answer

Conversion from MySQL to mysqli not working

I am in a process of converting my Existing MySQL to mysqli But I can't get this piece of code correct mysql_query("INSERT INTO `sendmsg`(`sendname`, `recievename`, `subject`, `body` , `mdate`, `mtime`) VALUES…
Sharan Mohandas
  • 861
  • 1
  • 9
  • 25
0
votes
1 answer

prepared INSERT statement to get insert_id to use in a second prepared INSERT statement

Im trying to create my own register form but im having issues with prepared statements. the idea is to create a prepared statement to insert info into the user table, then from that get the insert_id from the generated content to use in another…
Finbar Maginn
  • 257
  • 2
  • 11
0
votes
2 answers

Trying to insert into two tables using php and mysqli

I'm working on a blog with posts. I would like to insert into 3 tables Posts, Categories and Post_categories(to show the right category for a post) I tried everything using mysqli such as: $titel = $_POST['titel']; $post =…
Kees Sonnema
  • 5,759
  • 6
  • 51
  • 106
0
votes
2 answers

What are the better ways with INSERT on relational tables?

I'm experiencing my first mysql INSERT tests and I'm using these tables: table employees -> employee_id -> employee_name -> employee_surname -> employee_url table areas -> area_id -> area_city -> area_address -> area_country table agencies ->…
vitto
  • 19,094
  • 31
  • 91
  • 130
0
votes
1 answer

Both sql LAST_INSERT_ID() and PHP insert_id return 0

I've been searching google a lot for this issue and really found nothing. People just keep copying MySQL documentation on last_insert_id and nothing else. I've got an issue regarding last_insert_id, because for both situations (php & sql) it returns…
jakubplus
  • 307
  • 4
  • 17
0
votes
3 answers

codeigniter oracle get insert_id()

Working in CodeIgniter with Oracle database. Now the problem is $this->db->insert_id(); is not working here though it works perfectly in MySQL DB. The error report is: A Database Error Occurred This feature is not available for the database you are…
0
votes
0 answers

Using $insert_id to update two tables - codeigniter

Is there a way that I can update a form input using something like insert_id? I have a form for adding factories to a table and I use the insert_id to store the factories id in another table too after submit. this all works great, but is there such…
Kees Sonnema
  • 5,759
  • 6
  • 51
  • 106
0
votes
2 answers

Dependency in identity column values after multiple SQL inserts

If the next is right: There are SQL string with multiple inserts (using a stored procedure): "EXEC SPInsertData ... EXEC SPInsertData ... EXEC SPInsertData ..." The id in identity column, which is auto incremented, of every new record is smaller…
Kamarey
  • 10,832
  • 7
  • 57
  • 70
0
votes
1 answer

mysqli multi_query and insert_id gets me Commands out of sync;

I know similar questions have been asked, I've tried a bunch of them (including the php docs) but I don't seem to get this to work. I have the following: $query = "insert into page title values ('v1');insert into page title values ('v2');insert into…
Shivan Dragon
  • 15,004
  • 9
  • 62
  • 103
-1
votes
1 answer

PHP query insert_id not working

I want to add a user to the database. Every user has an unique ID that is automatic created(A_I). If I add an user I want to get this ID. I'm trying to do this with "insert_id", but if I do this I get an error. $sth=Connection()->prepare ("INSERT…
Wouter
  • 13
  • 2