PHP code example of romainbessugesmeusy / php-sql-query

1. Go to this page and download the library: Download romainbessugesmeusy/php-sql-query 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/ */

    

romainbessugesmeusy / php-sql-query example snippets


$select = new \RBM\SqlQuery\Select();
$select->setTable("project");
$select->setColumns(["project_id", "name"]);
$select->limit(0, 10);
	
$renderer = new \RBM\SqlQuery\RendererAdapter\MySql();
echo $renderer->render($select);
	
SELECT
	`project`.`project_id`
	, `project`.`name`
FROM
	`project`
LIMIT 0, 10

// do this once
\RBM\SqlQuery\Select::setDefaultRenderer("\RBM\SqlQuery\RendererAdapter");
// […]
$select = new \RBM\SqlQuery\Select("project", ["project_id", "name"]);
echo $select;

	$select = new Select('project', ['project_id', 'name']);
	$select->filter()
		   		->equals('owner_id', 1)
		   		->isNull('date_deleted');

	$select->filter()->subFilter()
					->operator('OR')
					->equals('status', 'DRAFT')
					->equals('status', 'PUBLISHED');