I am trying to get the id of the current inserted record. The field name is 
'id' and it is a primary key. I am obviously missing the correct syntax.
I cannot use RETURNING id.

$sql = "INSERT INTO jobs (job_title, num_positions, pay_min, pay_max,
                                                                startdate, 
enddate, job_desc, job_benefits, min_qualifications, employer_contact,
                                                                employer_phone, 
employer_email, stu_duties_id, stu_duties, grade_level,
                                                                
employer_school, send_to, reimbursement_amt, postdate)
                                                                VALUES 
('$job_title', '$num_positions', '$PAY_MIN', '$PAY_MAX',
                                                                '$startdate', 
'$enddate', '$job_desc', '$job_benefits', '$min_qualifications', 
'$employer_contact',
                                                                
'$employer_phone', '$employer_email', '$stu_duties_id', 
'$DUTIES_DESC[$stu_duties_id]', '$grade_level',
                                                                
'$employer_school', '$send_to', '$reimbursement_amt', '$postdate');";
                $sql .= "SELECT currval('id');";

                $result = pg_query($conn, $sql);
                $r = pg_fetch_object($result);
                $jobs_id = $r->id;
                echo "jobs id: " . $jobs_id . "<br />"; //echo is nothing

Any insight would be appreciated.

$sql echoed is this:
INSERT INTO jobs (job_title, num_positions, pay_min, pay_max, startdate, 
enddate, job_desc, job_benefits, min_qualifications, employer_contact, 
employer_phone, employer_email, stu_duties_id, stu_duties, grade_level, 
employer_school, send_to, reimbursement_amt, postdate) VALUES ('Paraeducator', 
'1', '9.50', '9.50', '9/16/2011', '6/10/2012', 'fdfd', 'fdfd', 'fdfd', 'firstn 
lastn', '3351', 'emai...@mail.com', '2', 'This position mostly tutors, 
instructs, or directly assists students. Less than half of the position tasks 
are clerical or support duties.', '10', '28', 'all', '70%', 
'09-20-2011');SELECT currval(id);

Marc

Reply via email to