Phactory\Sql\Blueprint::create PHP Method

create() public method

* Reify a Blueprint as a Row. Optionally use an array of associated objects to set fk columns.
public create ( $overrides = [], $associated = [] )
$associated [table name] => [Row]
    public function create($overrides = array(), $associated = array())
    {
        $built = $this->build($overrides, $associated);
        // process any many-to-many associations
        $many_to_many = array();
        foreach ($associated as $name => $row) {
            $association = $this->_associations[$name];
            if ($association instanceof Association\ManyToMany) {
                if (!is_array($row)) {
                    $row = array($row);
                }
                $many_to_many[$name] = array($row, $association);
            }
        }
        $built->save();
        if ($many_to_many) {
            $this->_associateManyToMany($built, $many_to_many);
        }
        return $built;
    }