saveall get all id save cakephp

Solutions on MaxInterview for saveall get all id save cakephp by the best coders in the world

showing results for - "saveall get all id save cakephp"
Dante
23 May 2019
1public $saved_ids = array(
2		'insert' => array(
3			'count' => 0, 'id' => array()
4		),
5		'update' => array(
6			'count' => 0, 'id' => array()
7		)
8    );
9
10
11function afterSave( $created, $options = array() ){
12		if( $created ){
13			$this->saved_ids['insert']['count']++;
14			$this->saved_ids['insert']['id'][] = $this->getID();	// get insert lasted id into database (vilh)
15		} else {
16			$this->saved_ids['update']['count']++;
17			$this->saved_ids['update']['id'][] = $this->getID();
18		}
19
20		return $this->saved_ids;
21	}
22
23
24if ($this->MemberBookFacility->saveAll($data_MemberBookFacility)) {
25
26	pr ($this->MemberBookFacility->saved_ids['insert']['id']);	// get multiple ids
27}