Configuration ============= The first thing you need to know about Idiorm is that *you don’t need to define any model classes to use it*. With almost every other ORM, the first thing to do is set up your models and map them to database tables (through configuration variables, XML files or similar). With Idiorm, you can start using the ORM straight away. Setup ~~~~~ First, ``require`` the Idiorm source file: .. code-block:: php 'value_for_setting_1', 'setting_name_2' => 'value_for_setting_2', 'etc' => 'etc' )); Use the ``get_config`` method to read current settings. .. code-block:: php 'mysql:host=localhost;dbname=my_database', 'username' => 'database_user', 'password' => 'top_secret' )); Result sets ^^^^^^^^^^^ Setting: ``return_result_sets`` Collections of results can be returned as an array (default) or as a result set. See the `find_result_set()` documentation for more information. .. code-block:: php 'SET NAMES utf8')); PDO Error Mode ^^^^^^^^^^^^^^ Setting: ``error_mode`` This can be used to set the ``PDO::ATTR_ERRMODE`` setting on the database connection class used by Idiorm. It should be passed one of the class constants defined by PDO. For example: .. code-block:: php 'person_id', 'role' => 'role_id', )); As with ``id_column`` setting, you can specify a compound primary key using an array. Limit clause style ^^^^^^^^^^^^^^^^^^ Setting: ``limit_clause_style`` You can specify the limit clause style in the configuration. This is to facilitate a MS SQL style limit clause that uses the ``TOP`` syntax. Acceptable values are ``ORM::LIMIT_STYLE_TOP_N`` and ``ORM::LIMIT_STYLE_LIMIT``. .. note:: If the PDO driver you are using is one of sqlsrv, dblib or mssql then Idiorm will automatically select the ``ORM::LIMIT_STYLE_TOP_N`` for you unless you override the setting. Query logging ^^^^^^^^^^^^^ Setting: ``logging`` Idiorm can log all queries it executes. To enable query logging, set the ``logging`` option to ``true`` (it is ``false`` by default). When query logging is enabled, you can use two static methods to access the log. ``ORM::get_last_query()`` returns the most recent query executed. ``ORM::get_query_log()`` returns an array of all queries executed. .. note:: The code that does the query log is an approximation of that provided by PDO/the database (see the Idiorm source code for detail). The actual query isn't even available to idiorm to log as the database/PDO handles the binding outside of idiorm's reach and doesn't pass it back. This means that you might come across some inconsistencies between what is logged and what is actually run. In these case you'll need to look at the query log provided by your database vendor (eg. MySQL). Query logger ^^^^^^^^^^^^ Setting: ``logger`` .. note:: You must enable ``logging`` for this setting to have any effect. It is possible to supply a ``callable`` to this configuration setting, which will be executed for every query that idiorm executes. In PHP a ``callable`` is anything that can be executed as if it were a function. Most commonly this will take the form of a anonymous function. This setting is useful if you wish to log queries with an external library as it allows you too whatever you would like from inside the callback function. .. code-block:: php