1. Go to this page and download the library: Download phpgt/sqlbuilder library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpgt / sqlbuilder example snippets
class StudentSelect extends SelectQuery {
public function select():array {
return [
"id",
"forename",
"surname",
"dateOfBirth",
];
}
public function from():array {
return [
"student",
];
}
}
class StudentSelectByAge extends StudentSelect {
public function where():array {
return [
"year(now()) - year(dateOfBirth) = :age",
];
}
}
// Start by using a base StudentSelect, then add a single inline condition to it.
$studentSelect = new StudentSelect();
$selectQuery = new SelectBuilder($studentSelect)
->where(
"year(now()) - year(dateOfBirth) = :age"
);
class StudentSelectByAge extends StudentSelect {
public function where():array {
return [
new AndCondition("year(now()) - year(dateOfBirth) = :age"),
new AndCondition("gender = :gender"),
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.