public function addRow(array $data = []) : int
    {
        $this->crudEnabled();

        $table_name = static::$table_name;

        if (0 == count($data)) {
            // Insert a blank row
            $sql = "INSERT INTO {$table_name} DEFAULT VALUES"; // TODO: Move this to the DAO class
            $this->dbc->query($sql);
        } else {
            // Generate the values
            $components = $this->dbc->generateParameterizedComponents($data);
            $fields = $components['fields'];
            $values = $components['values'];
            $params = $components['params'];

            // Execute the query
            $sql = "INSERT INTO {$table_name} ({$fields}) VALUES ({$values})";
            $this->dbc->query($sql, ['params' => $params]);
        }
        // Return the id of the new field
        return $this->dbc->lastInsertId();
    }
public function addRow(array $data = []) : int
    {
        $this->crudEnabled();

        $table_name = static::$table_name;

        if (0 == count($data)) {
            // Insert a blank row
            $sql = "INSERT INTO {$table_name} DEFAULT VALUES"; // TODO: Move this to the DAO class
            $this->dbc->query($sql);
        } else {
            // Generate the values
            $components = $this->dbc->generateParameterizedComponents($data);
            $fields = $components['fields'];
            $values = $components['values'];
            $params = $components['params'];

            // Execute the query
            $sql = "INSERT INTO {$table_name} ({$fields}) VALUES ({$values})";
            $this->dbc->query($sql, ['params' => $params]);
        }
        // Return the id of the new field
        return $this->dbc->lastInsertId();
    }
public function addRow ( array $ data = [ ] ) : int { $ this -> crudEnabled ( ) ; $ table_name = static :: $ table_name ; if ( 0 == count ( $ data ) ) { // Insert a blank row $ sql = "INSERT INTO {$table_name} DEFAULT VALUES" ; // TODO: Move this to the DAO class $ this -> dbc -> query ( $ sql ) ; } else { // Generate the values $ components = $ this -> dbc -> generateParameterizedComponents ( $ data ) ; $ fields = $ components [ 'fields' ] ; $ values = $ components [ 'values' ] ; $ params = $ components [ 'params' ] ; // Execute the query $ sql = "INSERT INTO {$table_name} ({$fields}) VALUES ({$values})" ; $ this -> dbc -> query ( $ sql , [ 'params' => $ params ] ) ; } // Return the id of the new field return $ this -> dbc -> lastInsertId ( ) ; }
Add a row to the table represented by this grid. If a table name, id column or structure for the table is not
defined above, this function will not work.

@param string[] $data The parameters to be added to the row
@return int The id of the generated row
@throws \Exception If required values have not been set on the child class.
Add a row to the table represented by this grid . If a table name id column or structure for the table is not defined above this function will not work .