Questions tagged [datamapper]

Architectural pattern for separating application logic from storage.

Objects and relational databases have different mechanisms for structuring data.

The Data Mapper is a layer of software that separates the in-memory objects from the database. Its responsibility is to transfer data between the two and also to isolate them from each other. With Data Mapper the in-memory objects needn't know even that there's a database present; they need no SQL interface code, and certainly no knowledge of the database schema.

Pattern definition: http://martinfowler.com/eaaCatalog/dataMapper.html

1130 questions
0
votes
1 answer

How do you use a row from one table as a property in another table using Datamapper?

The specific instance I am referring to is here. I want to use a row from the Grid table to be the value of the Grid property in the Driver table. But I cannot get updates in the Grid table to persist through to the Grid property on the Driver…
JoeyC
  • 550
  • 9
  • 19
0
votes
1 answer

How can I get DataMapper to return a sepcific number of elements?

say I have class MyClass include DataMapper::Resource property :id, Serial property :my_property, Text end How can I make a call to return a maximum of 3 items Such as MyClass.all(:my_property => "some_text", :max => 3) Where the :max =>…
Lev Dubinets
  • 766
  • 9
  • 29
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
  • 303
  • 3
  • 7
  • 21
0
votes
1 answer

Returning associated objects from Rails controller with Datamapper

I have two models which are related to one another (many to many) and I want to return them both in the response from my Rails controller action. The two classes are User and Location. There is also a link class UserLocation. User.rb looks…
Gerard
  • 4,688
  • 5
  • 48
  • 76
0
votes
2 answers

DataMapper: dm-timestamps doesn't play nice with dm-validations?

It seems that validations in DataMapper run before dm-timestamps has a chance to autoset the created_at and updated_at fields. Consider the following: require 'dm-core' require 'dm-migrations' require 'dm-timestamps' require 'dm-validations' class…
Jeremy Burton
  • 863
  • 6
  • 10
0
votes
1 answer

Transactions in Datamapper & Rails (dm-rails)

I have two models: hotel and location. A location belongs to a hotel, a hotel has one location. I'm trying to create both in a single form, bear in mind that I can't use dm-nested for nested forms due to a dependency clash. I have code that looks…
Gerard
  • 4,688
  • 5
  • 48
  • 76
0
votes
1 answer

multiple database connection in CI

can i connection with multiple database main connections is from database.php but the another one in from the model and i want to switch between it like this $config['remote']['hostname'] = 'localhost'; $config['remote']['username']…
dev.bashar
  • 181
  • 1
  • 2
  • 14
0
votes
1 answer

DataMapper Redis: can't find child from parent, only parent from child

I'm using DataMapper with the redis adapter in a Ruby library. I have these classes defined: class Zone include DataMapper::Resource property :id, String, :key => true, :unique_index => true, :default => lambda { |x,y| UUID.new.generate } …
lightyrs
  • 2,620
  • 2
  • 26
  • 31
0
votes
2 answers

Undefined method opts_from_validator_args

I just tried updating a project to use DataMapper 1.2 (from 1.1) and now I'm getting this error: /home/joe/.rvm/gems/ruby-1.9.2-p290@marketplace-admin/gems/dm-core-1.2.0/lib/dm-core/model/relationship.rb:372:in `method_missing': undefined method…
mltsy
  • 5,344
  • 1
  • 30
  • 41
0
votes
1 answer

Link shorthand application in Sinatra

This was my first Sinatra project - link shortener but I am stuck with some errors and to be honest sinatra's built-in debugger tells me literally nothing. I would like you to give me a clue or suggest a solution to problem.…
metrampaz
  • 641
  • 1
  • 6
  • 11
-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
  • 571
  • 2
  • 13
-1
votes
1 answer

Extract Excel data to transform to a simple XML

I am working on creating orders/receipts for a certain client that provides the data using Excel. However, it is not a common Excel table format but an actual form to be printed. I am having issues with the data mapper since it cannot be parsed…
Paul D.
  • 181
  • 1
  • 16
-1
votes
1 answer

Adding a table to datamapper gives me 'uninitialized constant' error

I'm trying to add a table to my app but when I do I get the error shown below. But I don't understand why? All I did was adding the Recommendation class. class Item include DataMapper::Resource property :id, Serial property :sortorder,…
Joel
  • 3,066
  • 5
  • 21
  • 26
-1
votes
1 answer

How can I resolve the IllegalContextError when attempting to save a datamapper model?

When I try to this code, I get an IllegalContextError at the "self.save..." line. Can you tell me what I'm doing wrong? I would just call the create method on Player without messing around with initialize, but I want a related week object to be…
JoeyC
  • 550
  • 9
  • 19
-1
votes
2 answers

Can I populate an object from a db but still have access to its methods?

This is my second post today because I'm very new at OOP in PHP, so bear with me if it's a silly question... I've created a beautiful class that I want to be able to use with my "JOB" objects that includes being able to use this single object to…
DevlshOne
  • 7,960
  • 1
  • 25
  • 33
1 2 3
75
76