DMZ 1.7.1 (DataMapper OverZealous Edition) |
[eluser]WanWizard[/eluser]
Just name your model 'juser', and in that model set $this->table to 'users' make override the models table name.
[eluser]gowrav vishwakarma[/eluser]
Quote:Just name your model ‘juser’, and in that model set $this->table to ‘users’ make override the models table name.its not that simple.. you have not noticed the relative field is UID not UID_id ... some how i have managed it to work now second problem .. and this can be helpful to other also I have a table members, and the members can have another members as friends its in another table stored as id | members_id | friends_members_id |approved status all good from one point "get all friends of member 87" but the point is in this social application a member can be at members_id as he added a friend or he can be at friends_members_id as his friend added him. now how to get all friends of a member and even only those who are approved !!!
[eluser]WanWizard[/eluser]
If you don't follow Datamapper's design guidelines, you're making it very difficult for yourself, and for us trying to support you. Self relationships in a many-to-many relation are described in the manual. Code: class Member extends DataMapper { This will require a relationship table called 'members_members', in which you will have the columns 'id', 'member_id', 'friend_id', and 'approved_status'. You can then get the list of John's approved friends by using Code: $member = new Member();
[eluser]gowrav vishwakarma[/eluser]
heads off to you... agreed i have to use guideline .. i am almost near what you said but major question As per your said I can get all friends of John if he has its id in member_id and friends id in friend_id, what if any of his friend added him in his list then also he is Johns friend. can there be a simple workaround in Datamapper since I am provided with database by my client this relation ship is in "jos_xshouts_members_has_friends" table with fields id | member_id | friend_member_id as per guideline I have gone to this ... Code: class Member extends DataMapper{ but $m=new Member(); $m->friend_member->get() gives nothing, I have also tried $m->member->get() .. but same .. Thanks for your time
[eluser]WanWizard[/eluser]
Use check_last_query() to see the query produced, and try to deduct from there what is wrong.
[eluser]gowrav vishwakarma[/eluser]
I have read the validation rules but what If i want to save a fields value in encrypted format but it should be displayed in normal way. like Code: $u=new User();
[eluser]WanWizard[/eluser]
To encrypt on save, see the prepping example in the documentation, it uses encrypt() as an example. To decrypt on retrieval, read the section in the manual about "Get Rules" (http://datamapper.wanwizard.eu/pages/getrules.html).
[eluser]Unknown[/eluser]
Hello, Im trying to use a group_by and a get_paged together, but when i use, the $object->paged->total_rows returns to me the total rows of the first group in the result. example: $object->group_by('value'); $object->get_paged($start, $lines_page, true); if the first row has 12 objects grouped and the result of the query has 2 rows, the $object->paged->total_rows returns to me 12 but the result should be 2. Am i doing something wrong?
[eluser]WanWizard[/eluser]
Have you tested this with the latest version? DMZ 1.7.x is no longer officially supported. If so, and it is still a problem, please create an ticket at https://bitbucket.org/wanwizard/datamapper/issues, describing the problem and linking back to your message here ( #857 in the titlebar on right gives you the correct link)?
[eluser]Dennis Rasmussen[/eluser]
This is just ridiculous... Could someone explain to me what kind of method they would use to do such a simple thing (yet so complicated with Datamapper) as being able to create/edit a row in table_1 while creating/updating relations to table_2 with a many:many relation? Code: table_1 So basically I'm having: - A controller to handle the create/update behavior - 2 models for the tables, both related to each other as many:many - A view with a formula with name input for table_1 and a multiselect element having options from table_2 When I submit I'd like the following to happen: - Create a new row in table_1 - Create rows in table_3 with relations between the new row in table_1 and the multiselected rows in table_2 All of this can easily be done without Datamapper, so why can't I with Datamapper? Sure I could just do the following, but that seriously can't be healthy for the server with all these objects being created for each relation? Code: foreach($this->input->post('multiselect') as $key => $id) Note that the variable names are changed for simplicity. |
Welcome Guest, Not a member yet? Register Sign In |