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

[eluser]brucebat[/eluser]
Hello,

Im trying to get a PK so I can use it for my Foreign Key in another table.

Would it be correct to use the get_where() function for this?

Heres my code.

Code:
//Patient segment
            $patient = array
            (
                'patient_age' =>$this->input->post ('patient_age'),
                'patient_height' => $this->input->post ('patient_height'),
                'patient_weight' => $this->input->post ('patient_weight'),
                'patient_gender' => $this->input->post ('patient_gender')
            );
        
            $insertpatient = $this->db->insert ('patient', $patient);
//Get PK for FK in next table
$patientfk = $this->db->get_where ('patient', array('patient_height' == $this->input->post('patient_height') && 'patient_weight' == $this->input->post('patient_weight')));

Im currently getting this error:

Quote:A Database Error Occurred

Error Number: 1054

Unknown column '0' in 'where clause'

SELECT * FROM (`patient`) WHERE `0` = 0

Filename: C:\xampp\htdocs\midas\system\database\DB_driver.php

Line Number: 330

I don't understand how it gets Column '0'?

Would it be because it does not specify correctly the column name?


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



Theme © iAndrew 2016 - Forum software by © MyBB