Orm

Orm is short for Object Relational Mapper which does 2 things: it maps your database table rows to objects and it allows you to establish relations between those objects.
It follows the Active Record Pattern closely, but was also influenced by other systems.

はじめに

他の多くのActiveRecordの実装とは異なり、小型で高速、さらに死ぬほど簡単に使えます。 それは簡単に、あなたのデータベースを項目を作成したり更新したり削除したりすることができるでしょう。 あなたのために、これらがすべてのハードワークを行います。

インストール

ORMパッケージは、ダウンロードされたFuelに含まれています。あなたの設定を有効にするだけです。

'packages' => array(
	'orm',
),

トラブルシューティング

一般的な問題とよくある質問。

リレーション/外部キーが保存されていません。 (1)

リレーションシップの間違った型を使用している場合に、最も頻繁に起こります。 特に Has-one と Belongs-to に混ざってしまいがちです。 ドキュメントの例を再読し、 あなたが正しくリレーションタイプを使用していることと、すべてが正しく設定されているかどうかを確認をしてください。.

オブジェクトを関連付けることができません (2)

あなたのモデルが Orm\Model を継承し、 Model_Crudを継承していない事を確認してください。

package/moduleの私の関連するモデルが見つからないという例外を取得しました

パッケージまたはモジュールがFuelによってロードされていることを確認してください。 それ以外のオートローダーは、クラスを見つけることができません。
そして、"model_to"と関連するモデルを設定するときは完全なクラス名を設定してください。 これは、あなたがその空間にいる場合でも名前空間が含まれています。 文字列内のクラス名は、常にグローバルコンテキストから取得されます。現在の名前空間コンテキストは関係ありません。

I get an Orm\FrozenObject exception

Objects can't be edited while being saved to the database, that prevents circular saving and resaving already saved objects. This shouldn't happen during normal usage and is most often caused by faulty configuration of relations.
Sometimes this can be caused by a bug, especially when you're not using a stable release.

I have defined a limit and offset, but the results are not correct

The ORM always makes sure that query results are consistent. If you run a query that contains related models, a subquery will be generated to make sure the entire related resultset is fetched. Even if this means more records then the limit you have set will be fetched. This is because once you start manipulating incomplete resultsets, very bad things might happen to your related models.

If you are absolutely sure you are not going to manipulate the results, for example because you need them for pagination only, you can use rows_limit() and rows_offset() instead, which will forces them on the entire query.