public function insert($entity)
    {
        $querySet = new QuerySet();
        $qb = $this->em->createQueryBuilder();
        $qb->insert($this->getTableName());
        $querySet->append($qb);
        $this->persist($querySet, $entity, ['id']);

        $result = $querySet->execute();

        // Try and set the entity id using the response from the insert
        try {
            $entity->setId($querySet->getInsertId());
        } catch (\Exception $e) {
        }

        return $result;
    }
public function insert($entity)
    {
        $querySet = new QuerySet();
        $qb = $this->em->createQueryBuilder();
        $qb->insert($this->getTableName());
        $querySet->append($qb);
        $this->persist($querySet, $entity, ['id']);

        $result = $querySet->execute();

        // Try and set the entity id using the response from the insert
        try {
            $entity->setId($querySet->getInsertId());
        } catch (\Exception $e) {
        }

        return $result;
    }
public function insert ( $ entity ) { $ querySet = new QuerySet ( ) ; $ qb = $ this -> em -> createQueryBuilder ( ) ; $ qb -> insert ( $ this -> getTableName ( ) ) ; $ querySet -> append ( $ qb ) ; $ this -> persist ( $ querySet , $ entity , [ 'id' ] ) ; $ result = $ querySet -> execute ( ) ; // Try and set the entity id using the response from the insert try { $ entity -> setId ( $ querySet -> getInsertId ( ) ) ; } catch ( \ Exception $ e ) { } return $ result ; }
Saves a new object into the database.

@param object $entity the entity to insert

@return bool
Saves a new object into the database .