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 |
|---|
__construct(string $table, array $data) : void
stringName of the database table where the INSERT operation will happen
arrayData that will be inserted into $table
exec() : string
Execute the constructed INSERT operation
string
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')"string
table : string
| var |
Database table |
|---|
string
data : array
| var |
Column data |
|---|
array