src/Sql/Manager.php
public function insertTable($meta, $query)
    {
        $meta = $meta instanceof Meta ? $meta : $this->mapper->getMeta($meta);
        if (!$meta->canInsert) {
            throw new Exception("Class {$meta->class} prohibits insert");
        }

        $query = $query instanceof Query\Insert ? $query : new Query\Insert(['values'=>$query]);
        $query->values = $this->mapper->mapPropertiesToRow($meta, $query->values);
        if (!$query->table) {
            $query->table = $meta->table;
        }

        list ($sql, $params) = $query->buildQuery($meta);
        // no need to formatParams here - they're already field names

        $stmt = $this->getConnector()->prepare($sql);
        $stmt->execute($params);
        $lastInsertId = $this->getConnector()->lastInsertId();
        return $lastInsertId;
    }
public function insertTable($meta, $query)
    {
        $meta = $meta instanceof Meta ? $meta : $this->mapper->getMeta($meta);
        if (!$meta->canInsert) {
            throw new Exception("Class {$meta->class} prohibits insert");
        }

        $query = $query instanceof Query\Insert ? $query : new Query\Insert(['values'=>$query]);
        $query->values = $this->mapper->mapPropertiesToRow($meta, $query->values);
        if (!$query->table) {
            $query->table = $meta->table;
        }

        list ($sql, $params) = $query->buildQuery($meta);
        // no need to formatParams here - they're already field names

        $stmt = $this->getConnector()->prepare($sql);
        $stmt->execute($params);
        $lastInsertId = $this->getConnector()->lastInsertId();
        return $lastInsertId;
    }
public function insertTable ( $ meta , $ query ) { $ meta = $ meta instanceof Meta ? $ meta : $ this -> mapper -> getMeta ( $ meta ) ; if ( ! $ meta -> canInsert ) { throw new Exception ( "Class {$meta->class} prohibits insert" ) ; } $ query = $ query instanceof Query \ Insert ? $ query : new Query \ Insert ( [ 'values' => $ query ] ) ; $ query -> values = $ this -> mapper -> mapPropertiesToRow ( $ meta , $ query -> values ) ; if ( ! $ query -> table ) { $ query -> table = $ meta -> table ; } list ( $ sql , $ params ) = $ query -> buildQuery ( $ meta ) ; // no need to formatParams here - they're already field names $ stmt = $ this -> getConnector ( ) -> prepare ( $ sql ) ; $ stmt -> execute ( $ params ) ; $ lastInsertId = $ this -> getConnector ( ) -> lastInsertId ( ) ; return $ lastInsertId ; }
Insert values into a table

insertTable ( $meta , array $propertyValues );
insertTable ( $meta , Query\Insert $query );

- $meta can be an instance of Amiss\Meta or a class name.
- $propertyValues keys must exist in the corresponding Meta.

@return int|null
Insert values into a table