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
string
Name of the database table where the INSERT operation will happen
array
Data 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