mothership-ec / cog

Cog
Other
2 stars 3 forks source link

Added `addParams()` and `run()` method to QueryBuilder #461

Closed thomasjthomasj closed 9 years ago

thomasjthomasj commented 9 years ago

This PR allows developers to add parameters adhoc to the query builder, for instance:

$foo = 'bar';
$queryBuilder->select(':foo?s')
    ->from('table')
    ->addParams(['foo' => $foo])
    ->getQueryString();

will return SELECT bar FROM table.

This change means that getQueryString() parses all queries before returning them, so the unit tests have been amended as such. Unfortunately, the new methods themselves still need unit tests as trying to test them with Mockery was proving too painful. Feel free to try and write them.

It also allows the query to be run directly from the query builder, mainly as a convenience thing, so instead of $queryBuilder->getQuery()->run() we can just run $queryBuilder->run()