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

[eluser]Damir Sivic[/eluser]
and why doas not work for me, I used fresh copy of CI, Datamapper 1.8.2, and simplest example... and everything works except dump_tree and dump_dropdown
#52

[eluser]WanWizard[/eluser]
Please define "not work"? What happens? Error messages?
#53

[eluser]Damir Sivic[/eluser]
that is the problem, no errors, just an blank page, but when I change a variable "$_rootfield" to NULL (nestedsets.php) all starts to work
#54

[eluser]WanWizard[/eluser]
Well, this is exactly what you should do if your table doesn't have a root column.

In the config, set 'root' to NULL.

(p.s. it should be NULL by default, as written in the manual. I don't know why it is not so in the code, might be a leftover of some testing).
#55

[eluser]ricardocasares[/eluser]
Sorry, this comes from codeigniter .com/forums/viewreply/979474/, I re posted because I'm using 1.8.2 instead of 1.8.0

Hi guys, I'm struggling to set up the validation rules to validate the related items on a specific object, ie: A user can have no more than 3 products related to it.

I believe DataMapper can check for this validation using _related_max_size rule in Related validation, but I can't figure out how to use it on the $validation array in the model.

So far I've tried this in both my user and product models:

Code:
var $validation = array(
    'product' => array(
         'rules' => array('max_size' => 3)
    )
);

Can somebody show me an example on how to set up this at the model, controller and finally the view (specificly how to show the errors for this)?

Edit: What I mean is, a user has many products, and can create a certain amount of them, let's say 3 products, when that amount is reached, the user can no longer create products, and this validation rule should not permit the user to create more products.

This would be the DB Schema:

Code:
Users table
------------------
id   |  username  |
------------------

Code:
Products table
------------------------
id  | user_id |  name   |
------------------------

Thanks!
#56

[eluser]WanWizard[/eluser]
I already answered there... Wink

Doesn't really matter, the answer is the same for 1.8.0 and 1.8.2.
#57

[eluser]PatrickGalbraith[/eluser]
I am not sure if this has been posted yet and I can't access the issue tracker on bitbucket.

I just installed Datamapper 1.8.2 on an existing site. Previously I had to modify the core database files and remove the protected functions. Everything worked fine out of the box with the new bootstrap method except when using the count() function.

Code:
$m = new Message();
$new_messages_count = $m->where_related_user('id', $this->ion_auth->get_user()->id)->where_join_field('user', 'is_sender', 0)->where_join_field('user', 'is_deleted', 0)->where_join_field('user', 'is_read', 0)->count();

This is the code I am using and it throws this error

Code:
PHP Fatal error:  Cannot access protected property DM_DB_Driver::$_count_string in /application/libraries/datamapper.php on line 2588

I have fixed this temporarily by changing:
Code:
protected $_count_string = 'SELECT COUNT(*) AS ';
to
Code:
public $_count_string = 'SELECT COUNT(*) AS ';
in system/database/drivers/mysql/mysql_driver.php

#58

[eluser]WanWizard[/eluser]
Oops, indeed something I've missed.

That line should read:
Code:
$select = $this->dm_get('_count_string');
#59

[eluser]NiconPhantom[/eluser]
Hi guys,

I wasn't using DataMapper before, but I really like the functionality of it and I am in process of implementation.

I have one small question, if I'll work with DB + DataMapper ORM, will it auto escape all the queries like it's implemented in Active Record?

Thanks a lot,

Alex
#60

[eluser]WanWizard[/eluser]
Datamapper actually uses CI's database classes, including "active record", to access the database.

So yes, everything CI does, Datamapper does too.




Theme © iAndrew 2016 - Forum software by © MyBB