lib/public/AppFramework/Db/Mapper.php
/**
	 * Creates a new entry in the db from an entity
	 * @param Entity $entity the entity that should be created
	 * @return Entity the saved entity with the set id
	 * @since 7.0.0
	 */
Creates a new entry in the db from an entity
@param Entity $entity the entity that should be created
@return Entity the saved entity with the set id
@since 7.0.0
Creates a new entry in the db from an entity @param Entity $entity the entity that should be created @return Entity the saved entity with the set id @since 7 . 0 . 0
public function insert(Entity $entity){
		$properties = $entity->getUpdatedFields();
		$values = '';
		$columns = '';
		$params = [];
		$i = 0;
		foreach($properties as $property => $updated) {
			$column = $entity->propertyToColumn($property);
			$getter = 'get' . ucfirst($property);
			$columns .= '`' . $column . '`';
			$values .= '?';
			if($i < count($properties)-1){
				$columns .= ',';
				$values .= ',';
			}
			$params[] = $entity->$getter();
			$i++;
		}
		$sql = 'INSERT INTO `' . $this->tableName . '`(' .
				$columns . ') VALUES(' . $values . ')';
		$stmt = $this->execute($sql, $params);
		$entity->setId((int) $this->db->lastInsertId($this->tableName));
		$stmt->closeCursor();
		return $entity;
	}
public function insert ( Entity $ entity ) { $ properties = $ entity -> getUpdatedFields ( ) ; $ values = '' ; $ columns = '' ; $ params = [ ] ; $ i = 0 ; foreach ( $ properties as $ property => $ updated ) { $ column = $ entity -> propertyToColumn ( $ property ) ; $ getter = 'get' . ucfirst ( $ property ) ; $ columns .= '`' . $ column . '`' ; $ values .= '?' ; if ( $ i < count ( $ properties ) - 1 ) { $ columns .= ',' ; $ values .= ',' ; } $ params [ ] = $ entity -> $ getter ( ) ; $ i ++ ; } $ sql = 'INSERT INTO `' . $ this -> tableName . '`(' . $ columns . ') VALUES(' . $ values . ')' ; $ stmt = $ this -> execute ( $ sql , $ params ) ; $ entity -> setId ( ( int ) $ this -> db -> lastInsertId ( $ this -> tableName ) ) ; $ stmt -> closeCursor ( ) ; return $ entity ; }
Creates a new entry in the db from an entity
 @param Entity $entity the entity that should be created
 @return Entity the saved entity with the set id
 @since 7.0.0
Creates a new entry in the db from an entity @param Entity $entity the entity that should be created @return Entity the saved entity with the set id @since 7 . 0 . 0
// get updated fields to save, fields have to be set using a setter to // be saved // build the fields // only append colon if there are more entries