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
2
votes
1 answer

Basic CRUD operations with Codeigniter and Datamapper

I'm totally new at Codeigniter and Datamapper and i have a very fundamental question that can't be answered by myself searching in the documentation. I have a very simple database with 3 tables: student courses student_courses Now, i understand…
liebgott
  • 21
  • 4
2
votes
1 answer

How to get data from two table and order by second table Datamapper

My first table is product and second table is user In product table column is id, user_id,prname etc; In user table column is id, user_name, rating. I used this for get $user = new User(); $user ->get(); $products = new Product(); $products…
2
votes
2 answers

Datamapper (Overzealous Edition), Codeigniter and Has Many Clarification

Firstly, I would like to just it out there that I am an ORM noob. I've never used an ORM in my life and have reached a point in my day-to-day developing that I need to do some crazy advanced relationships that I believe Datamapper Overzealous…
Dwayne Charrington
  • 6,524
  • 7
  • 41
  • 63
2
votes
2 answers

Printing Column count(*) in codeigniter

I am fetching data from a database like this. select categories.categorie_name, count(*) from names join categories on names.categories_id=categories.categories_id group by categories.categorie_name order by 2 i got as a result 2 columns …
Rubenex
  • 469
  • 2
  • 8
  • 23
2
votes
1 answer

Codeigniter : How to make the nested selection for related tables

I have two tables in my database one for "LOUNGES" and one for "CITIES". There isn't an explicit connection between them. I mean I haven't put a column "city_id" in the "LOUNGES TABLE". I just take the "name" column from "CITIES" and choose it for a…
Unsparing
  • 6,985
  • 2
  • 17
  • 33
2
votes
1 answer

Update (save & delete) relationship without using $related->get();

I'm using codeigniter 2.1.4 & datamapper orm. I know how to save relations to an object and I know how to delete them. In this case I have a many-to-many relation, which I want to update with new values from a form. Now I can use this to save them…
Wietse
  • 372
  • 7
  • 18
2
votes
0 answers

Datamapper and CI: is not a valid parent relationship

I have 2 models from tables I need to relate, campus: class Campus extends Datamapper { var $table='campi'; var $has_many=array('boleto'); function __construct() { parent::__construct(); } } And boleto: class Boleto…
Laura
  • 21
  • 3
2
votes
2 answers

Codeigniter Datamapper - self-relationship - include_related()

I am looking at how to create self-relationship (upsteam) join in ORM Datamaper. my self - relation class looks: array( 'class' => 'prospect', …
Pawel
  • 21
  • 3
2
votes
3 answers

How to sum and count together using Codeigniter Datamapper?

I want to do something like this with Codeigniter Wanwizard Datamapper. SELECT COUNT(amount), SUM(amount) FROM mytable Basically I want to extract both the total amount and how many row included in a single query. But I couldn't find a way in the…
Ricky L
  • 23
  • 4
1
vote
1 answer

Many to Many DataMapper CodeIgniter

I'm stuck and reading the documentation doesn't seem to be helping me out. I have one to many relationships working, all though I'm sure there is an easier way, I'm stuck when it comes to Many to Many relationships. I've tried quite a few things,…
Seth
  • 6,240
  • 3
  • 28
  • 44
1
vote
2 answers

Codeigniter Datamapper set Object attributes from Post Data

Is there a way to automatically/dynamically set all the attributes for a datamapper object instead of assigning them one for one? So my form field names are exactly the same as the attributes from the datamapper model. So is there a shorter way to…
Simon
  • 1,643
  • 7
  • 30
  • 61
1
vote
1 answer

How to access newly saved related objects in Datamapper ORM

I am using Datamapper ORM 1.8.2.1 with CodeIgniter 2.1.0 and I have trouble accessing newly added related objects from within a parent. I have a parent class like this: class Virement extends DataMapper { var $has_many = array("lignevirement"); …
IhariR
  • 21
  • 4
1
vote
1 answer

CodeIgniter DataMapper ORM include_related always returning first row in database table

I have a user model and a user_profile model and I am trying to get a specific user and the related user_profile with the following function. if I comment out the include_related line it works and gets the user based on user_id but if I try to use…
user794846
  • 1,881
  • 5
  • 29
  • 72
1
vote
1 answer

CodeIgniter dependencies between models, without using any ORM or DataMapper systems

I'm writing a CRUD system using CodeIgniter, implementing some 'one to many' dependencies between models (without using any ORM or DataMapper systems) by calling methods from one model to another. For example: in a "many Documents per User"…
Alon
  • 83
  • 1
  • 4
1
vote
1 answer

Many to one and Many to many on same objects using datamapper ORM in Codeigniter

I have an application that requires: user owns many projects. project has one owner. user works on many projects. projects have many users. so I have 3 tables, users, projects_users, projects. The relationships are: one user (owner) --- many…
Stevo
  • 2,601
  • 3
  • 24
  • 32
1 2
3
16 17