src/EasyDB.php
public function insert(string $table, array $map): int
    {
        if (!empty($map)) {
            if (!$this->is1DArray($map)) {
                throw new Issues\MustBeOneDimensionalArray(
                    'Only one-dimensional arrays are allowed.'
                );
            }
        }

        list($queryString, $values) = $this->buildInsertQueryBoolSafe(
            $table,
            $map
        );
        /** @var string $queryString */
        /** @var array $values */

        return (int) $this->safeQuery(
            (string) $queryString,
            $values,
            \PDO::FETCH_BOTH,
            true
        );
    }
public function insert(string $table, array $map): int
    {
        if (!empty($map)) {
            if (!$this->is1DArray($map)) {
                throw new Issues\MustBeOneDimensionalArray(
                    'Only one-dimensional arrays are allowed.'
                );
            }
        }

        list($queryString, $values) = $this->buildInsertQueryBoolSafe(
            $table,
            $map
        );
        /** @var string $queryString */
        /** @var array $values */

        return (int) $this->safeQuery(
            (string) $queryString,
            $values,
            \PDO::FETCH_BOTH,
            true
        );
    }
public function insert ( string $ table , array $ map ) : int { if ( ! empty ( $ map ) ) { if ( ! $ this -> is1DArray ( $ map ) ) { throw new Issues \ MustBeOneDimensionalArray ( 'Only one-dimensional arrays are allowed.' ) ; } } list ( $ queryString , $ values ) = $ this -> buildInsertQueryBoolSafe ( $ table , $ map ) ; /** @var string $queryString */ /** @var array $values */ return ( int ) $ this -> safeQuery ( ( string ) $ queryString , $ values , \ PDO :: FETCH_BOTH , true ) ; }
Insert a new row to a table in a database.

@param  string $table - table name
@param  array  $map   - associative array of which values should be assigned to each field
@return int
@throws \InvalidArgumentException
@throws \TypeError
Insert a new row to a table in a database .