diff options
-rw-r--r-- | README.markdown | 18 | ||||
-rw-r--r-- | idiorm.php | 7 | ||||
-rw-r--r-- | test/test_queries.php | 8 |
3 files changed, 28 insertions, 5 deletions
diff --git a/README.markdown b/README.markdown index 30ed852..2e6e6b5 100644 --- a/README.markdown +++ b/README.markdown @@ -36,6 +36,11 @@ Changelog * Add `distinct` method * Add `group_by` method +#### 1.1.1 - release 2011-01-30 + +* Fix bug in quoting column wildcard. j4mie/paris#12 +* Small documentation improvements + Philosophy ---------- @@ -58,10 +63,17 @@ First, `require` the Idiorm source file: require_once 'idiorm.php'; -Then, pass a *Data Source Name* connection string to the `configure` method of the ORM class. This is used by PDO to connect to your database. For more information, see the [PDO documentation](http://uk2.php.net/manual/en/pdo.construct.php). Particularly, if you need to pass a username and password to your database driver, use the `username` and `password` configuration options. See "Configuration" section below. - +Then, pass a *Data Source Name* connection string to the `configure` method of the ORM class. This is used by PDO to connect to your database. For more information, see the [PDO documentation](http://uk2.php.net/manual/en/pdo.construct.php). ORM::configure('sqlite:./example.db'); +You may also need to pass a username and password to your database driver, using the `username` and `password` configuration options. For example, if you are using MySQL: + + ORM::configure('mysql:host=localhost;dbname=my_database'); + ORM::configure('username', 'database_user'); + ORM::configure('password', 'top_secret'); + +Also see "Configuration" section below. + ### Querying ### Idiorm provides a [*fluent interface*](http://en.wikipedia.org/wiki/Fluent_interface) to enable simple queries to be built without writing a single character of SQL. If you've used [jQuery](http://jquery.com) at all, you'll be familiar with the concept of a fluent interface. It just means that you can *chain* method calls together, one after another. This can make your code more readable, as the method calls strung together in order can start to look a bit like a sentence. @@ -116,7 +128,7 @@ Only a subset of the available conditions supported by SQL are available when us These limits are deliberate: these are by far the most commonly used criteria, and by avoiding support for very complex queries, the Idiorm codebase can remain small and simple. -Some support for more complex conditions and queries is provided by the `where_raw` and `raw_select` methods (see below). If you find yourself regularly requiring more functionality than Idiorm can provide, it may be time to consider using a more full-featured ORM. +Some support for more complex conditions and queries is provided by the `where_raw` and `raw_query` methods (see below). If you find yourself regularly requiring more functionality than Idiorm can provide, it may be time to consider using a more full-featured ORM. ##### Equality: `where`, `where_equal`, `where_not_equal` ##### @@ -899,10 +899,13 @@ /** * This method performs the actual quoting of a single - * part of an identifier. Currently uses backticks, which - * are compatible with (at least) MySQL and SQLite. + * part of an identifier, using the identifier quote + * character specified in the config (or autodetected). */ protected function _quote_identifier_part($part) { + if ($part === '*') { + return $part; + } $quote_character = self::$_config['identifier_quote_character']; return $quote_character . $part . $quote_character; } diff --git a/test/test_queries.php b/test/test_queries.php index e227e27..329ebc9 100644 --- a/test/test_queries.php +++ b/test/test_queries.php @@ -210,6 +210,14 @@ $expected = "DELETE FROM `widget` WHERE `id` = '1'"; Tester::check_equal("Delete data", $expected); + // Regression tests + + $widget = ORM::for_table('widget')->select('widget.*')->find_one(); + $expected = "SELECT `widget`.* FROM `widget` LIMIT 1"; + Tester::check_equal("Issue #12 - incorrect quoting of column wildcard", $expected); + + // Tests that alter Idiorm's config are done last + ORM::configure('id_column', 'primary_key'); ORM::for_table('widget')->find_one(5); $expected = "SELECT * FROM `widget` WHERE `primary_key` = '5' LIMIT 1"; |