PHP Connector Check quantity before insert

Hello,

I want to know how to check quantity (count) before insert process
ex: I want to put my books to a box with max quantity 50

function doOnBeforeInsert() {
//Count my books already inserted. If quantity <50 “insert process OK”, If >= 50 “insert process fail”
}

$conn->event->attach(“beforeInsert”,doOnBeforeInsert);
$conn->render_table(“books”,“id”,“title,author,sales”);

Thanks

Connector doesn’t provide any DB access helpers, you can get DB connection object as $this->db and run any kind of db operations to get a necessary info

So I must write my own code. There is one thing I want to know when I am using Form to save data with POST Method (debug by Firebug).

Without dataProcessor (myForm.send)
address New address
name Andy

With dataProcessor
1436226462626_!nativeedit… inserted
1436226462626_address New address
1436226462626_name Andy
ids 1436226462626

How could you get this random value for ids ?

There is a POST[“ids”] that will contain this id, or you can use

dp.setTransactionMode("POST", false);
It will revert format of sent data to the same as in case of form.send, but you will need to use a custom code, as connector will not be able to parse it.

Ooh…Thank you