ClanCats Hydrahon Versions Save

🐉 Fast & standalone PHP MySQL Query Builder library.

v1.1.14

3 years ago

Fixed a few more type hints.

v1.1.13

3 years ago

A small quality of live release. I've added a lot of missing type hints and fixed wrong ones. This has been long overdue but should now ease working with and IDE.

v1.1.12

4 years ago
  • Fixed an error where table aliases where not being set.
  • Fixed identifier escaping, thanks @lucasnodari
  • Added whereNotIn helper, thanks @AeonFr :

     $people->select()->whereNotIn('city', ['Zürich', 'Bern', 'Basel'])->get(); 
    
  • Fixed travis build

v1.1.11

5 years ago

This release fixes an error when trying to pass multiple expression to an order by statement:

$h->table('people')->select()
  ->orderBy([new Expression('rand()'), new Expression('rand()')])
  ->execute();
select * from `people` order by func1() asc, func2() asc

There is currently no way changing the direction per order statement in the array syntax. So the direction is set for all given order statements in the array.

$h->table('people')->select()
  ->orderBy([new Expression('func1()'), new Expression('func2()')], 'desc')
  ->execute();
select * from `people` order by func1() desc, func2() desc

The fix should also allow mixed arrays:

$h->table('people')->select()
  ->orderBy(['name' => 'asc', new Expression('func()')], 'desc')
  ->execute();
select * from `people` order by `name` asc, func() desc

v1.1.10

5 years ago

This release brings support for replace queries.

Example:

$h->table('movie_title')->replace([
    'movie_id' => '1', 
    'language' => 'de', 
    'title' => 'Der Fluch der Karibik'
])->execute();

results in the following query string:

replace into `movie_title` (`language`, `movie_id`, `title`) values (?, ?, ?)

v1.1.9

5 years ago

Fixed custom select query object inheritance.

The Select class is now able to fully inherit its properties from a parent select class.

Example:

class BurgerQuery extends ClanCats\Hydrahon\Query\Sql\Select
{
    public function onlyTastyOnes()
    {
        $this->where('tasty', 1);
    }
}

$query = new BurgerQuery(
    $h->table('burgers')->select()->limit(50)
);

$query->onlyTastyOnes();

$tastyBurgers = $query->get();

v1.1.8

6 years ago

Changes

Feature: query flags

Query flags allow you to store parameters inside a query object. This can be very useful when passing a query object through multiple modifiers.

$movies = $h->table('movies');

$movies->join('review', 'review.movie_id', '=', 'review.id');
$movies->setFlag('reviewIsJoined', true);

// somewhere later ...

if ($movies->getFlag('reviewIsJoined', false)) {
    $movies->orderBy('review.rating');
}

v1.1.7

7 years ago

1.1.7 is a really small release and changes the following:

Changes

  • Added PHPUnit 4 as a dev dependency. Tests should be from now on executed using vendor/bin/phpunit.
  • PHP Doc fix in the table method to make the life of IDE users better. Thanks @kingmaryjonatan.

v1.1.6

7 years ago

This releases does not add any new features but makes the implementation a bit easier.

Changes

  • Removed php 5.3 support. This thing is old, really, really old it's time to say goodbye.
  • Added FetchableInterfaceThis makes it easy for you to identify if a query should be fetched or not.

Example from the readme has been updated:

$connection = new PDO('mysql:host=localhost;dbname=my_database', 'username', 'password');

$hydrahon = new \ClanCats\Hydrahon\Builder('mysql', function($query, $queryString, $queryParameters) use($connection)
{
    $statement = $connection->prepare($queryString);
    $statement->execute($queryParameters);

    if ($query instanceof \ClanCats\Hydrahon\Query\Sql\FetchableInterface)
    {
        return $statement->fetchAll(\PDO::FETCH_ASSOC);
    }
});

v1.1.5

7 years ago

Features

I've added an EXISTS query object allowing you to do a query like this one:

SELECT EXISTS(select id from showtimes) as hasShows

Like that:

$h->table('showtimes')->select()->exists(); // returns bool true

Obviously that select query can do everything like the normal select.

$h->table('showtimes')
    ->select()
    ->where(function($q)
    {
        $q->where('start', '>', time());
        $q->orWhere('end', '<', time() + 3600);
    })
    ->exists();