Welcome Guest, Not a member yet? Register   Sign In
[solved]Getting a Primary Key after inserting into a table?
#5

[eluser]Mirge[/eluser]
If you had a table like:

Code:
CREATE TABLE test (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
patient_name VARCHAR(50) NOT NULL,
patient_weight INT UNSIGNED NOT NULL,
...rest of your fields here...
);

id would be your primary key.

Code:
$result = $this->db->insert("....");
$id = $this->db->insert_id();

echo "The primary key (id) for the record I just inserted is $id";

See: http://ellislab.com/codeigniter/user-gui...lpers.html


Messages In This Thread
[solved]Getting a Primary Key after inserting into a table? - by El Forum - 07-05-2011, 09:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB