Skip to content

Commit

Permalink
Prepend PHP tag in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
treffynnon committed Feb 28, 2013
1 parent c3520a8 commit bc56239
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ First, ``require`` the Idiorm source file:

.. code-block:: php
<?php
require_once 'idiorm.php';
Then, pass a *Data Source Name* connection string to the ``configure``
Expand All @@ -22,6 +23,7 @@ database. For more information, see the `PDO documentation`_.

.. code-block:: php
<?php
ORM::configure('sqlite:./example.db');
You may also need to pass a username and password to your database
Expand All @@ -30,6 +32,7 @@ For example, if you are using MySQL:

.. code-block:: php
<?php
ORM::configure('mysql:host=localhost;dbname=my_database');
ORM::configure('username', 'database_user');
ORM::configure('password', 'top_secret');
Expand All @@ -47,13 +50,15 @@ wish to modify and the value you wish to set it to.

.. code-block:: php
<?php
ORM::configure('setting_name', 'value_for_setting');
A shortcut is provided to allow passing multiple key/value pairs at
once.

.. code-block:: php
<?php
ORM::configure(array(
'setting_name_1' => 'value_for_setting_1',
'setting_name_2' => 'value_for_setting_2',
Expand All @@ -72,6 +77,7 @@ this:

.. code-block:: php
<?php
ORM::configure('mysql:host=localhost;dbname=my_database');
ORM::configure('username', 'database_user');
ORM::configure('password', 'top_secret');
Expand All @@ -81,6 +87,7 @@ configuration array shortcut:

.. code-block:: php
<?php
ORM::configure(array(
'connection_string' => 'mysql:host=localhost;dbname=my_database',
'username' => 'database_user',
Expand All @@ -97,6 +104,7 @@ See the `find_result_set()` documentation for more information.

.. code-block:: php
<?php
ORM::configure('return_result_sets', true); // returns result sets
Expand All @@ -118,6 +126,7 @@ the connection:

.. code-block:: php
<?php
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
PDO Error Mode
Expand All @@ -131,6 +140,7 @@ class constants defined by PDO. For example:

.. code-block:: php
<?php
ORM::configure('error_mode', PDO::ERRMODE_WARNING);
The default setting is ``PDO::ERRMODE_EXCEPTION``. For full details of
Expand Down Expand Up @@ -174,6 +184,7 @@ all tables. If your ID column is called ``primary_key``, use:

.. code-block:: php
<?php
ORM::configure('id_column', 'primary_key');
Setting: ``id_column_overrides``
Expand All @@ -185,6 +196,7 @@ the table, you can use the following configuration:

.. code-block:: php
<?php
ORM::configure('id_column_overrides', array(
'person' => 'person_id',
'role' => 'role_id',
Expand Down
2 changes: 2 additions & 0 deletions docs/connections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ calls in the chain use the correct connection.

.. code-block:: php
<?php
// Default connection
ORM::configure('sqlite:./example.db');
Expand Down Expand Up @@ -51,6 +52,7 @@ query on *any* connection.

.. code-block:: php
<?php
// Using default connection, explicitly
$person = ORM::for_table('person')->find_one(5);
Expand Down
9 changes: 9 additions & 0 deletions docs/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ simply by accessing the property on the object directly:

.. code-block:: php
<?php
$person = ORM::for_table('person')->find_one(5);
// The following two forms are equivalent
Expand All @@ -27,6 +28,7 @@ be returned.

.. code-block:: php
<?php
$person = ORM::for_table('person')->create();
$person->first_name = 'Fred';
Expand All @@ -51,6 +53,7 @@ update multiple properties at once, by passing in an associative array:

.. code-block:: php
<?php
$person = ORM::for_table('person')->find_one(5);
// The following two forms are equivalent
Expand All @@ -74,6 +77,7 @@ expressions using the ``set_expr`` method.

.. code-block:: php
<?php
$person = ORM::for_table('person')->find_one(5);
$person->set('name', 'Bob Smith');
$person->age = 20;
Expand All @@ -92,6 +96,7 @@ instance. You then set values on the object as normal, and save it.

.. code-block:: php
<?php
$person = ORM::for_table('person')->create();
$person->name = 'Joe Bloggs';
Expand All @@ -111,6 +116,7 @@ expressions using the ``set_expr`` method.

.. code-block:: php
<?php
$person = ORM::for_table('person')->create();
$person->set('name', 'Bob Smith');
$person->age = 20;
Expand All @@ -129,6 +135,7 @@ created (or last saved), call the ``is_dirty`` method:

.. code-block:: php
<?php
$name_has_changed = $person->is_dirty('name'); // Returns true or false
Deleting records
Expand All @@ -139,13 +146,15 @@ method.

.. code-block:: php
<?php
$person = ORM::for_table('person')->find_one(5);
$person->delete();
To delete more than one object from the database, build a query:

.. code-block:: php
<?php
$person = ORM::for_table('person')
->where_equal('zipcode', 55555)
->delete_many();
Expand Down
Loading

0 comments on commit bc56239

Please sign in to comment.