CodeIgniter Forums
DataMapper 1.6.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: DataMapper 1.6.0 (/showthread.php?tid=11358)



DataMapper 1.6.0 - El Forum - 02-02-2009

[eluser]OverZealous[/eluser]
I don't remember, but I think this is a bug in DM I've had as well.

I'm pretty sure the best solution is to write the query like this:
Code:
// notice, using where_related instead of $z->ad
$count = $ad->where_related($z)->where('active', TRUE)->count();

This should run without error. You might also need to write it as:
Code:
$count = $ad->where_related($z)->where('ads.active', TRUE)->count();
If the active column occurs in both zones and ads.


DataMapper 1.6.0 - El Forum - 02-03-2009

[eluser]macigniter[/eluser]
has anyone had problems that timestamps wouldn't be saved although the fields are named "created" and "updated" in the database?

it seems that dm just wouldn't save or update my timestamps Sad

this is what i have in my config file:

Code:
$config['created_field'] = 'created';
$config['updated_field'] = 'updated';
$config['local_time'] = FALSE;
$config['unix_timestamp'] = TRUE;



DataMapper 1.6.0 - El Forum - 02-03-2009

[eluser]tdktank59[/eluser]
@ the guy with the SQL problem

Check the mysql driver ( the troubleshoot page ibln the manual has the info)


@macigniter
Timestamps are working fine for me. At least I think they are.


DataMapper 1.6.0 - El Forum - 02-03-2009

[eluser]OverZealous[/eluser]
@macigniter
Are you getting an error, or are they just not being updated?
If the latter, are they never being updated, or just some of the time?
What is the type of field are you using?


DataMapper 1.6.0 - El Forum - 02-03-2009

[eluser]macigniter[/eluser]
I did not get an error message. They just haven't been updated (actually they showed up as "0000-00-00 00:00:00" in PhpMyAdmin.

Weird enough (although I didn't change anything) it does work now. The field type is "timestamp".

Very strange... I'll keep an eye on it!


DataMapper 1.6.0 - El Forum - 02-03-2009

[eluser]tdktank59[/eluser]
Is there a way to get thing out of the relation table?

For example: I need to get start_date and end_date from the roles_users table

Quote:users
id
username
email
password
etc...

join_roles_users
id
role_id
user_id
created_on
updated_on
start_date
end_date


roles
id
name
description
created_on

UPDATE:
For the moment im just using custom queries attached to the page and method models. If there is a way to do it with Datamapper sweet otherwise this is a work around for it at the moment...


DataMapper 1.6.0 - El Forum - 02-03-2009

[eluser]OverZealous[/eluser]
@tdtank59
You're using the only working solution for now. (I'm doing likewise.)

The closest alternative (and I don't recommend it) is to create a dedicated model that contains the relationships and the extra info. That ends up generating even more queries.


DataMapper 1.6.0 - El Forum - 02-04-2009

[eluser]stensi[/eluser]
@tdktank59: Yeah, there's currently no way to grab items from the joining tables. That's one of the many features I want to include in coming versions. You might want to look back through the posts at what commandercool has posted since I think he might have posted something relating to this issue.

____________________________

Just as an update to everyone, sorry for not being that active lately! I'm currently busy with 2 projects and as such I'll have very little spare time for DataMapper until they're complete.

I'm yet to really have a proper look at the added functionality by commandercool and OverZealous.com but they'll be the first things I get into after the project work is over, which may be a while...


DataMapper 1.6.0 - El Forum - 02-04-2009

[eluser]bEz[/eluser]
:question: Not to distract to much from DM development, so I apologize if I'm asking for help by replying to the DM thread.

In a previous app, I managed a league DB using the following setup (just a few of the many tables used).
Code:
seasons (seasonID, ..., ..., ...)
conferences (conferenceID, seasonID, ..., ..., ...)
divisions (divisionID, conferenceID, ..., ..., ...)
teams (teamID, divisionID, ..., ..., ...)
players (playerID, teamID, ..., ..., ...)
Now that I'm utilizing DM, I'm restructuring this schema as follows:

NORMAL TABLES
Code:
seasons (id, ...)
conferences (id, ...)
divisions (id, ...)
teams (id, ...)
players (id, ...)
apparently I would need the following as well:

JOIN TABLES
Code:
conferences_seasons (id, conference_id, season_id)
conferences_divisions (id, conference_id, division_id)
divisions_teams (id, division_id, team_id)
players_teams (id, player_id, team_id)
What I need to confirm are the following:
(A) Am I required to create other join tables (divisions_seasons, seasons_teams, ...) in order to pull data? (the user guide has been helpful, but I'm still in learning mode)

(B) Can I possibly get a few examples, best approaches, to populating the join tables.
Quote:i.e:
I create a new season (object & data of course).
for that season I create two conferences
in each conference I create two divisions
in each division I create approxitmately 6 teams
on each team I create 15 players.

The entire approach can be inserted using cookie cutter data (season1, conference1, conference2, division1, division2, team1, team2, ...) or each entity 1 at a time.
If cookie cutter, I could utilize a datagrid to update the data after temporary data has been "saved", which brings up another request:

© Has anyone used a datagrid CI implementation with DM?


DataMapper 1.6.0 - El Forum - 02-04-2009

[eluser]bEz[/eluser]
Addendum to (A) above:
Would additional join tables be required to access relationships of another object?
Conferences => Divisions
Divisions => Teams
Teams => Players

In order to determine all the players in a conference, would it require
conferences_players (id, conferences_id, players_id)

or would the association of the other join tables be enough to somehow access that relationship?