1. Go to this page and download the library: Download gajus/klaus 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/ */
gajus / klaus example snippets
[
'name' => 'foo_name', // User input name
'value' => '1', // User input value
'operator' => '=' // Condition operator
]
/**
* @param array $query
* @param array $map Map input name to the aliased column in the SQL query, e.g. ['name' => '`p1`.`name`'].
*/
$where = new \Gajus\Klaus\Where($query, $map);
/**
* @return string SQL WHERE clause representng the query.
*/
$where->getClause();
$sql = "
SELECT
`f1`.`name`,
`b1`.`name`
FROM
`foo` `f1`
INNER JOIN
`bar` `b1`
ON
[..]
WHERE
{$where->getClause()}
";
$sth = $db->prepare($sql);
/**
* @return array Input mapped to the prepared statement bindings present in the WHERE clause.
*/
$input = $where->getInput();
$sth->execute($input);