PHP code example of mamadou-aly-sy / query-builder
1. Go to this page and download the library: Download mamadou-aly-sy/query-builder 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/ */
mamadou-aly-sy / query-builder example snippets
Builder = new \MamadouAlySy\QueryBuilder();
$query = $queryBuilder
->from('user')
->select()
->everything()
->getQuery();
$sql = $query->getSql();
$parameters = $query->getParameters();
namespace MamadouAlySy\Interfaces;
interface ConnectionInterface
{
public function open(): \PDO;
}
// Create the user table
$queryBuilder->create()
->table('users')
->field('id')->int()->notNull()->autoIncrement()
->field('username')->string()->default('mamadou')
->commit();
// Getting all users
$users = $queryBuilder
->from('user')
->select()->everything()
->get();
// Getting one user
$user = $queryBuilder
->from('user')
->where('id')->equal(1)
->select()->everything()
->first();
// Insert a user
$queryBuilder
->insert(['username' => 'Mamadou'])->into('user')
->commit();