how to catch err in $recs = $db->getrows($qry);
==================================
i have simple single table node.
in postadd() - i m inserting in another table which has a constraint bcoz of which insert may fail.
I wish to catch that error - that the insert failed. How to do it?
Code:
:
function postadd()
{
:
:
//insert in another table
$qry = "INSERT INTO va_locked_slot (va_emp_id,slot_number,capacity_req_date,capacity_req_tm_fr,booking_mode
,created_by,created_date, request_id
)";
$qry .= " VALUES ('$operator', '$slot_number','$capacity_req_date','$capacity_req_tm_fr', '$booking_mode'
,'$userid', '$created_date', '$request_id'
)" ;
$recs = $db->getrows($qry); >>>>> how to catch constraint error here
/*
table stru for refernece
DROP TABLE IF EXISTS va_locked_slot;
CREATE TABLE va_locked_slot
(
va_emp_id INT(11) NOT NULL,
slot_number INT(11) NOT NULL, -- this can be dropped suggested by dhananjay acc primary key will change
capacity_req_tm_fr VARCHAR(10) NOT NULL, -- (x 11:15, 11:30 etc) addn suggested by dhananjay acc primary key will change
capacity_req_date VARCHAR(20) NOT NULL,
booking_mode VARCHAR(10) , -- addn suggested by dhananjay
created_date VARCHAR(20),
created_by INT(11),
request_id INT(11),
PRIMARY KEY(va_emp_id,capacity_req_tm_fr,capacity_req_date)
);
*/
}