OpenBuildings/jam — pull request #32 by hkdobrev (2013-11-09 18:55:05+00:00)
Title: Overhaul of Jam_Query_Builder_Insert. Fixes #31.

In short this will:
* Change it to be more consistent with Database_Query_Builder_Insert.
* Fix small bugs in `params()` and `__call()`.
* Add real unit tests. `compile()` and `execute()` are still to be tested.
* Fix PHPDoc.
* Change `Jam::insert()` accordingly.
* Fix docs.

See the squashed commits below for more details.

commit a3fa684efb00b24070abfb3ae777fb59c572f647
Author: Haralan Dobrev
Date: Sat Nov 9 20:32:49 2013 +0200

Fix docs for `Jam::insert()`

Basically the previous documentation for `Jam::insert()` was a shameless
copy of the documentation of `Jam::update`.
Wrong SQL examples like:
INSERT INTO clients SET title = 'Patrik', username = 'patrik76'
are removed.

Added more/better examples for:
* inserting a single record
* using the columns argument
* using a sub query

commit 87a410a229183c92e7b77ecdbd608c1c02926ac8
Author: Haralan Dobrev
Date: Sat Nov 9 20:32:45 2013 +0200

Make `Jam::insert()` support columns

commit 5973a87698876774d4a8c5228790d8a2d58126b1
Author: Haralan Dobrev
Date: Sat Nov 9 20:32:21 2013 +0200

Add unit tests for Jam_Query_Builder_Insert

commit c0a825558e8e366d4e46bd1f7277d0d14db1966f
Author: Haralan Dobrev
Date: Sat Nov 9 20:31:15 2013 +0200

Improve PHPDoc for Jam_Query_Builder_Insert methods

commit 342063c2bdd75033c9b7c5d7e12539918ce78f9f
Author: Haralan Dobrev
Date: Sat Nov 9 20:29:46 2013 +0200

Fix Jam_Query_Builder_Insert::__call()

When the called function return a non-NULL, evaluating-to-FALSE value,
it should be returned instead of $this.
Indented code to not go over 80 characters per line.

commit a591ffb9aeb2d99ee1cd00efa03cc7f8aaf3d7f9
Author: Haralan Dobrev
Date: Sat Nov 9 20:26:48 2013 +0200

Fix Jam_Query_Builder_Insert::params()

* Merging of params should happen with a priority for the new params.
* When the first argument is an array and the second argument is not NULL,
an exception should not be thrown, but the second argument to be ignored instead.
* Code is cleaner by using recursion for the simpler (key, value) case.

commit 0f10d7519dac0d008ae82f8169f2247ef9e67544
Author: Haralan Dobrev
Date: Sat Nov 9 20:18:40 2013 +0200

Allow passing columns to insert builder constructor

Allow passing a `$columns` array to `Jam_Query_Builder::__constructi()`
and respectively to `Jam_Query_Builder_Insert::factory()`.

Use `parent::__construct()` to set the table and the columns.

Notes:

The previous statement about the first argument is simply not true:
http://git.io/JOvVqA
> `$model` is not actually allowed to be NULL. It has
a default because PHP throws strict errors otherwise.

From PHP documentation:
http://php.net/manual/en/language.oop5.decon.php
> Unlike with other methods, PHP will **not** generate an E_STRICT level error
message when __construct() is overridden with different parameters than
the parent __construct() method has.