Welcome Guest, Not a member yet? Register   Sign In
DataMapper ORM v1.8.2

[eluser]WanWizard[/eluser]
Smile No problem.

[eluser]coldscooter[/eluser]
How can i do multiple joins?

In this statement it will attempt to run the second 'include_related' on the original 'user' object, when I want it to include_related on the 'post' object.

User->include_related('post', null, true, true)->include_related('sometable')

Note: So the third table is dependant on the User id and Post id.

Every time i run it i get "Unable to relate sometable with user"

[eluser]WanWizard[/eluser]
If 'sometable' is a child of 'post', you would use include_related('post/sometable').

[eluser]coldscooter[/eluser]
Thank you

[eluser]Stolz[/eluser]
For some reason the automated timestamps are not working for me.

After creating or updating the obketcs, in the data base all my 'created' column values are '0000-00-00 00:00:00' and the 'updated' are set to NULL. Do I need any kind of special settings for MySQL/PHP for the automated timestamps to work?

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

My tables look like:

Code:
CREATE TABLE item (
id smallint(1) unsigned NOT NULL auto_increment PRIMARY KEY,
name varchar(64) NOT NULL UNIQUE,
created datetime NOT NULL,
updated datetime
) ENGINE=InnoDB

[eluser]WanWizard[/eluser]
If you don't use a unix timestamp, Datamapper uses the 'timestamp_format' to convert the unix timestamp using strtotime().

The way Datamapper configurations work:
- if your model has a property with the name of a config key, that will be used
- if your config/datamapper.php file has the config key, that will be used
- otherwise it will use the Datamapper default value

In this case, I don't know if you have defined it in the model, but you have defined it in the config file, so that value will be used. Unfortunately, "" is not a valid strtotime() format string, so the date will be set to FALSE, which MySQL will convert to NULL as it is not a valid value for the column.

So, either remove the definition, or set it to the correct value ('Y-m-d H:iConfused' for a MySQL DATETIME column).

[eluser]Stolz[/eluser]
Thanks WanWizard, commenting out the $config['timestamp_format'] for using the DM default did the trick Smile

[eluser]coldscooter[/eluser]
Am i able to add a where() to an include_related()?

[eluser]WanWizard[/eluser]
You should be able to combine it with where_related().

It might not work in all cases with deep relations ('parent/child/grandchild' notation).

[eluser]coldscooter[/eluser]
What params does where_related expect? I can't see it documented in the manual.

Code:
$this
      ->user
      ->sometable1
      ->include_related('sometable2', null, true, true)
      ->include_related('sometable2/sometable3')
      ->where_related()
      ->get();

So i want to say where sometable3 relates to sometable1. Is this possible?

Edit:
I also want to join rather than left outer join. How can i do this?




Theme © iAndrew 2016 - Forum software by © MyBB