Questions tagged [codeigniter-datamapper]

An ORM library for CodeIgniter that builds on CodeIgniter's existing ActiveRecord library. Despite its name, it does not use the DataMapper pattern, but is instead an implementation of the ActiveRecord pattern.

DataMapper is an Object-Relational Mapper that builds on ActiveRecord. Data is loaded from database tables into objects, and relationships can be managed through simple, easy-to-read functions.

DataMapper ORM adds several important features to original DataMapper library, further enhancing it's usage, usually without requiring any code changes.

DataMapper offers these features:

  • Everything is an object!
  • Easy to setup, easy to use.
  • Custom Validation on object properties.
  • Lazy Loading (related objects are only loaded upon access).
  • Relations and their integrity are automatically managed for you.
  • One to One, One to Many, and Many to Many relations fully supported.
  • Select data in the style of Active Record (with or without Method Chaining).

Datamapper User Guide: http://datamapper.wanwizard.eu/
CodeIgniter wiki page: http://codeigniter.com/wiki/DataMapper_ORM/
Current release discussions : http://codeigniter.com/forums/viewthread/190990/

247 questions
3
votes
3 answers

Codeigniter Datamapper - Add tablename by __construct

In my CMS I want to add modules by creating a table in the database. But Codeigniter with datamappers has one mandatory rule: give the tablename in your code. I have create a Datamapper model as following: class Module_universeel extends DataMapper…
3
votes
1 answer

CodeIgniter DataMapper ORM unable to instantiate model object

I am creating a model object like this: $object1 = new Object1(); There is a table in the database named object1s. The Object1 class is an empty class that extends DataMapper. That works without problems. I am able to save data, and retrieve…
mdl
  • 171
  • 1
  • 8
2
votes
1 answer

Codeigniter Datamapper many to many list

I have 2 many to many relationship tables; Posts and Categories. One post can have many categories. My question is how can I show list of posts with their categories? Like that: My post 1 (cat1, cat2, cat3) My post 2 (cat2, cat3) My post 3…
musa
  • 1,457
  • 18
  • 37
2
votes
3 answers

codeigniter datamapper relationship validation issues

I need to set up the validation rules to validate the related items on a specific object, ie: A user can have no more than 3 products related to it. I believe DataMapper can check for this validation using _related_max_size rule, but I can't figure…
analogic.al
  • 739
  • 2
  • 11
  • 19
2
votes
1 answer

duplicate data avoiding in codeigniter datamapper !? PHP

I am inserting the Food(table) keys/enteries into the DB and I get duplicate keys even though I am not suppose to based on the manual. I am really confused and stuck!? Relationship is as follows: every user has a related to many different food…
Majic Johnson
  • 341
  • 3
  • 15
2
votes
1 answer

Run a function before a model is saved to the database in DataMapper ORM and CodeIgniter

Is there a way to run a function/callback before a model is saved using Datamapper ORM in CodeIgniter? I know this is possible in most ORMs where you can hook into certain points such as before_update, before_create and so on. Basically I want to…
Nick Barrett
  • 1,051
  • 2
  • 11
  • 28
2
votes
1 answer

codeigniter datamapper

I am using CodeIgniter 2.1.0 and MySQL. I want to display a horizontal data row as a vertical one. When I fetch a single row from the database and echo it, it looks like ---------------------------------------- id | name | address | email …
Pritom
  • 61
  • 7
2
votes
1 answer

How to nest WHERE params in Datamapper ORM for Codeigniter?

I am having trouble with a specific query, using Datamapper ORM for Codeigniter. My data model is set up so that I have blog posts, each of which have many categories, users, and tags. I want to fetch blog posts that are related to a specific…
suzubara
  • 23
  • 3
2
votes
1 answer

Codeigniter/Datamapper "where_related" causing too many queries

I have a many-to-many mapping between profiles and categories. This query: $profiles = new Profile(); $profiles->where('foobar_flag',1); $profiles->where_related($category); $profiles->get(); Is taking almost 30 seconds to run, with about 1000…
djvs
  • 552
  • 2
  • 11
2
votes
1 answer

Codeigniter 2 + Datamapper ORM: Adjacency Lists, how to set model relation for it?

Q: How to set models for Adjacency Lists, when using Datamapper ORM. Anyone experienced ? For example, Table Category ( id, name, has_parent_category_id ). Thanks for looking! Example table, Tbl Category id | name | has_parent_category_id 1 | catA…
punkbit
  • 7,347
  • 10
  • 55
  • 89
2
votes
2 answers

CodeIgniter: datamapper ORM delete() a relation;

I have a tables called users, countries, and countries_users. The documentation states that to delete a simple relationship you perform: // Get user foo $u = new User(); $u->where('username', 'foo')->get(); // Get country object for Australia $c =…
Jordan Arsenault
  • 7,100
  • 8
  • 53
  • 96
2
votes
1 answer

Selecting rows that corresponds from other table

I have a product table that stores all products. Also I have a production table that stores productions. I am using CodeIgniter and datamapper ORM. Here is tables: CREATE TABLE IF NOT EXISTS `products` ( `id` int(10) unsigned NOT NULL…
Valour
  • 773
  • 10
  • 32
2
votes
1 answer

CodeIgniter DataMapper Problem with Relationship

Hey i've got a pretty simple relationship in my Datamapper model.. in my model Ticket i hav: var $has_one = array("user"); and when i try to $ticket->user->get()->username; it says: DataMapper Error: 'ticket' is not a valid parent relationship…
soupdiver
  • 3,504
  • 9
  • 40
  • 68
2
votes
3 answers

Connecting to mulitple databases with DMZ DataMapper

I'm using the DMZ DataMapper ORM for CodeIgniter. I'm sure it is possible to configure it to connect to multiple databases. I haven't found any documentation yet. Has anyone done this before?
indi
  • 386
  • 3
  • 15
2
votes
3 answers

Codeigniter 3 - Query Builder 'join' Method '!=' operator is not giving expected output

Not a Duplicate Question!!! I am using CodeIgniter 3 - Query Builder Class with MySQLi. Tables in DB: 'category_level_1' Table: 'category_level_2' Table: Query in model.php: $query = $this->db ->select('category_level_1.id,…
1
2
3
16 17