src/Arvici/Heart/Database/Driver/PDOConnection.php
public function insert($table, array $data)
    {
        // Prepare
        $columnPart = "";
        $valuePart = "";

        // Loop the data
        foreach ($data as $column => $value) {
            $columnPart .= "`$column`, ";
            $valuePart .= "?, ";
        }

        // Remove last commas
        $columnPart = substr($columnPart, 0, -2);
        $valuePart = substr($valuePart, 0, -2);

        $query = "INSERT INTO `$table` ($columnPart) VALUES ($valuePart)";


        // Prepare and bind
        $statement = $this->prepare($query);

        $idx = 0;
        foreach ($data as $key => $value) {
            $statement->bindValue(($idx+1), $value, Database::typeOfValue($value));
            $idx++;
        }

        // Execute and return the execute returning value.
        return $statement->execute();
    }
public function insert($table, array $data)
    {
        // Prepare
        $columnPart = "";
        $valuePart = "";

        // Loop the data
        foreach ($data as $column => $value) {
            $columnPart .= "`$column`, ";
            $valuePart .= "?, ";
        }

        // Remove last commas
        $columnPart = substr($columnPart, 0, -2);
        $valuePart = substr($valuePart, 0, -2);

        $query = "INSERT INTO `$table` ($columnPart) VALUES ($valuePart)";


        // Prepare and bind
        $statement = $this->prepare($query);

        $idx = 0;
        foreach ($data as $key => $value) {
            $statement->bindValue(($idx+1), $value, Database::typeOfValue($value));
            $idx++;
        }

        // Execute and return the execute returning value.
        return $statement->execute();
    }
public function insert ( $ table , array $ data ) { // Prepare $ columnPart = "" ; $ valuePart = "" ; // Loop the data foreach ( $ data as $ column => $ value ) { $ columnPart .= "`$column`, " ; $ valuePart .= "?, " ; } // Remove last commas $ columnPart = substr ( $ columnPart , 0 , - 2 ) ; $ valuePart = substr ( $ valuePart , 0 , - 2 ) ; $ query = "INSERT INTO `$table` ($columnPart) VALUES ($valuePart)" ; // Prepare and bind $ statement = $ this -> prepare ( $ query ) ; $ idx = 0 ; foreach ( $ data as $ key => $ value ) { $ statement -> bindValue ( ( $ idx + 1 ) , $ value , Database :: typeOfValue ( $ value ) ) ; $ idx ++ ; } // Execute and return the execute returning value. return $ statement -> execute ( ) ; }
Insert data into the table. Will make a query for you and prepare the statement with the data.

@param string $table
@param array $data

@throws DatabaseException

@return bool Successful inserted?
Insert data into the table . Will make a query for you and prepare the statement with the data .