If the database schema is not compatible with this bean and
RedBean runs in frozen mode it will throw an exception.
This function returns the primary key ID of the inserted
bean.
The return value is an integer if possible. If it is not possible to
represent the value as an integer a string will be returned. We use
explicit casts instead of functions to preserve performance
(0.13 vs 0.28 for 10000 iterations on Core i3).
/** * Stores a bean in the database. This method takes a * OODBBean Bean Object $bean and stores it * in the database. If the database schema is not compatible * with this bean and RedBean runs in fluid mode the schema * will be altered to store the bean correctly. * If the database schema is not compatible with this bean and * RedBean runs in frozen mode it will throw an exception. * This function returns the primary key ID of the inserted * bean. * * The return value is an integer if possible. If it is not possible to * represent the value as an integer a string will be returned. We use * explicit casts instead of functions to preserve performance * (0.13 vs 0.28 for 10000 iterations on Core i3). * * @param OODBBean|SimpleModel $bean bean to store * * @return integer|string */ public function store($bean) { $bean = $this->unboxIfNeeded($bean); $id = $this->repository->store($bean); if (self::$autoClearHistoryAfterStore) { $bean->clearHistory(); } return $id; }
/** * Stores a bean in the database. This method takes a * OODBBean Bean Object $bean and stores it * in the database. If the database schema is not compatible * with this bean and RedBean runs in fluid mode the schema * will be altered to store the bean correctly. * If the database schema is not compatible with this bean and * RedBean runs in frozen mode it will throw an exception. * This function returns the primary key ID of the inserted * bean. * * The return value is an integer if possible. If it is not possible to * represent the value as an integer a string will be returned. We use * explicit casts instead of functions to preserve performance * (0.13 vs 0.28 for 10000 iterations on Core i3). * * @param OODBBean|SimpleModel $bean bean to store * * @return integer|string * * @throws Security */ public function store($bean) { $bean = $this->unboxIfNeeded($bean); return $this->repository->store($bean); }