Insert

Insert class

This class holds all the information regarding INSERT operation, that will be used by Database class.

Example

$data = [
 "name": "John Doe"
];
$insertOperation = new Insert('User', $data);
$insertOperation->exec();
package

Default

Methods

__construct

__construct(string $table, array $data) : void

Arguments

$table

string

Name of the database table where the INSERT operation will happen

$data

array

Data that will be inserted into $table

exec

exec() : string

Execute the constructed INSERT operation

Response

string

toString

toString() : string

Return the SQL query

Example

$data = [
 "name": "John Doe"
];
$insertOperation = new Insert('User', $data);
echo $insertOperation->toString();
// Returns "INSERT INTO User (name) VALUES ('John Doe')"

Response

string

Properties

Database table

table : string
var

Database table

Type(s)

string

Column data

data : array
var

Column data

Type(s)

array