public function insert(string $table, array $e): \PDOStatement
    {
        if (sizeof($e) == 0) {
            trigger_error('array passed in Connection::insert(...) is empty.', E_ERROR);
        }

        $query = "INSERT INTO $table (";
        $values = '';
        foreach ($e as $campo => $v) {
            $query .= $campo . ',';
            $values .= '\'' . $this->escape($v) . '\',';
        }
        $query[strlen($query) - 1] = ')';
        $values[strlen($values) - 1] = ')';
        $query .= ' VALUES (' . $values . ';';

        self::$id = parent::lastInsertId($table);

        return $this->query($query);
    }
public function insert(string $table, array $e): \PDOStatement
    {
        if (sizeof($e) == 0) {
            trigger_error('array passed in Connection::insert(...) is empty.', E_ERROR);
        }

        $query = "INSERT INTO $table (";
        $values = '';
        foreach ($e as $campo => $v) {
            $query .= $campo . ',';
            $values .= '\'' . $this->escape($v) . '\',';
        }
        $query[strlen($query) - 1] = ')';
        $values[strlen($values) - 1] = ')';
        $query .= ' VALUES (' . $values . ';';

        self::$id = parent::lastInsertId($table);

        return $this->query($query);
    }
public function insert ( string $ table , array $ e ) : \ PDOStatement { if ( sizeof ( $ e ) == 0 ) { trigger_error ( 'array passed in Connection::insert(...) is empty.' , E_ERROR ) ; } $ query = "INSERT INTO $table (" ; $ values = '' ; foreach ( $ e as $ campo => $ v ) { $ query .= $ campo . ',' ; $ values .= '\'' . $ this -> escape ( $ v ) . '\',' ; } $ query [ strlen ( $ query ) - 1 ] = ')' ; $ values [ strlen ( $ values ) - 1 ] = ')' ; $ query .= ' VALUES (' . $ values . ';' ; self :: $ id = parent :: lastInsertId ( $ table ) ; return $ this -> query ( $ query ) ; }
Insert a series of elements into a table in the database

@param string $table: Table to which elements are to be inserted
@param array $e: Associative arrangement of elements, with the 'field_en_la_tabla' => 'value_to_insertar_en_ese_campo',
all elements of the array $ e, will be healed by the method without having to do it manually when creating the array...

@return object \PDOStatement
Insert a series of elements into a table in the database