Answers for "saveAll get all id save cakephp"

PHP
1

saveAll get all id save cakephp

public $saved_ids = array(
		'insert' => array(
			'count' => 0, 'id' => array()
		),
		'update' => array(
			'count' => 0, 'id' => array()
		)
    );


function afterSave( $created, $options = array() ){
		if( $created ){
			$this->saved_ids['insert']['count']++;
			$this->saved_ids['insert']['id'][] = $this->getID();	// get insert lasted id into database (vilh)
		} else {
			$this->saved_ids['update']['count']++;
			$this->saved_ids['update']['id'][] = $this->getID();
		}

		return $this->saved_ids;
	}


if ($this->MemberBookFacility->saveAll($data_MemberBookFacility)) {

	pr ($this->MemberBookFacility->saved_ids['insert']['id']);	// get multiple ids
}
Posted by: Guest on March-11-2021

Browse Popular Code Answers by Language