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

getting difficulty in generating the Dyanmic checkbox from the database

I am using Codeigniter and Datamapper for DB Query. My controller is as follows function fetch_interested_in() { $in = new Interested_in(); $in -> get(); $interested_in = array(); foreach($in -> all as $data) { …
Shashi Roy
  • 323
  • 3
  • 7
  • 22
0
votes
1 answer

CI2 hmvc datamapper

Fatal error: Allowed memory size of 194217728 bytes exhausted (tried to allocate 261904 bytes) in C:\xampp\htdocs\test\ci\application\libraries\datamapper.php on line 5 What is the problem? It works right but when trying to run any datamapper…
0
votes
1 answer

CodeIgniter Wanwizard DM Join other field

Tables Upload Fields id|user_id|link|status Upload_acc Fields id|user_id|name|password Upload Acc Model var $table = 'Upload'; var $has_one =…
user905476
0
votes
1 answer

DataMapper all_to_json() method returning slashes

I just found DataMapper for CI's built in to_json and all_to_json methods, which saved me a ton of time. How can I return relations with the result? Currently my code looks like this: $homes = new…
Seth
  • 6,240
  • 3
  • 28
  • 44
0
votes
1 answer

Avoiding duplicates Database records in a datamapper code igniter

My Question is simply how to insert data into the join table(user_book) without inserting a duplicate entry into the main table(book). Mainly consider we have tree table below id Users id Books id Users Books 1 Sam 1 B1 1 1 1 …
Majic Johnson
  • 341
  • 3
  • 15
0
votes
2 answers

array is overwritten by the last element in php

The result stored in $g is 1 and 2. The following code I've written below, my $array['music'] stores only the last element that is 2. But what I want is to execute my sql query 2 times under foreach and match the value of $g which is 1 and 2 with…
Shashi Roy
  • 323
  • 3
  • 7
  • 22
0
votes
1 answer

errors with the name of the table in Datamapper ( city )

I've a model called City in datamapper for codeigniter. I've kept the name of the table as "cities" because datamapper expects the name of the table in pluralized form. Now when I create the object for the model in controller ( $c = new City(); ); I…
Shashi Roy
  • 323
  • 3
  • 7
  • 22
0
votes
2 answers

munal connection database CodeIgniter

i need to connect for many databases the primary connection in the database.php and there is no problem with that but the another connections must be in Model i use this class
dev.bashar
  • 191
  • 1
  • 2
  • 14
0
votes
1 answer

CodeIgniter how to connect multi database using database.php for first connection and Model for second connection

I have many database connection i have primary connection in the database.php file $active_group = 'default'; $active_record = TRUE; $db['default']['hostname'] = 'xxx'; $db['default']['username'] = 'xxx'; $db['default']['password'] =…
dev.bashar
  • 191
  • 1
  • 2
  • 14
0
votes
1 answer

How to hydrate a custom property in DataMapper PHP constructor based on FK relationship

So I have two objects. class Product extends DataMapper { var $has_many = array('productrating'); public $averageRating = null; function __construct($id = NULL) { parent::__construct($id); echo "my id: " .…
Jeff
  • 340
  • 1
  • 4
  • 16
0
votes
1 answer

CodeIgniter and ORM (datamapper)

i'm new to php and codeigniter but i have experience with pylons and sqlalchemy. there you define model classes and then you use command something like "paster setup-app development.ini" and (paster?) creates tables for you and you dont have to…
karantan
  • 885
  • 10
  • 18
0
votes
2 answers

Save many to many relationship in datamapper ORM - Codeigniter

I am a beginner. Here I would to ask all of you that how can I save many to many relationship in to the three tables(table A , table A-b , table B)? Now I am trying to save a new record with new ID into table A, and I have some IDs of table B that I…
chantheoun
  • 31
  • 3
-1
votes
1 answer

Check if one object is related to another with Datamapper

Using Codeigniter and Datamapper: I have 2 tables: tags and clients. Clients can have many tags, tags can have many clients. I am using a separate join table to save the relationships. I have a page for managing an individual tag, where I am…
Wesley Murch
  • 101,186
  • 37
  • 194
  • 228
-1
votes
3 answers

How to get count of the sql search query?

How to get count of the sql search query $u = new user(); $sql = "SELECT a.id FROM `accounts` AS a LEFT JOIN `users` AS u ON a.id = u.id WHERE a.id IS NOT NULL "; $gender = $this->input->post('gender'); if($gender != NULL) { $sql .= "AND…
Yahiya
  • 761
  • 4
  • 15
-1
votes
1 answer

Error Number: 1096 Error Number: 1096 No tables

class model_trans_gc extends CI_Model{ function trans_gc_add() { $add=array( 'trans_gc_date' => $this->input->post('trans_gc_date'), 'trans_gc_no' => $this->input->post('trans_gc_no'), …
1 2 3
16
17