EllisLab text mark
Advanced Search
31 of 32
31
   
[Deprecated] DMZ 1.6.2 (DataMapper OverZealous Edition)
Posted: 13 April 2010 02:19 AM   [ # 461 ]   [ Rating: 0 ]
Joined: 2008-09-20
45 posts

Can anyone take a look on my unanswered question? it is here http://ellislab.com/forums/viewreply/695462/

 Signature 

Sorry for my pour english [2] :(

 
Posted: 02 May 2010 01:28 PM   [ # 462 ]   [ Rating: 0 ]
Avatar
Joined: 2010-01-29
32 posts

Delete several rows

I want to delete all students wich are 17 years old.
I can’t get it with this simple code. It just deletes one by one, instead of deleting all rows. What’s wrong?

//Set age
$age 17;

// Get student
$u = new Student();
$u->where('age'$age)->get();

// Delete user
$u->delete(); 
 
Posted: 02 May 2010 11:15 PM   [ # 463 ]   [ Rating: 0 ]
Avatar
Joined: 2008-10-08
1039 posts

Wazzu
Delete only acts on the top-level item.  Search the manual for delete_all - this is what you need.

 Signature 

Phil DeJarnett
  OverZealous Creations, LLC

 
Posted: 03 May 2010 03:09 AM   [ # 464 ]   [ Rating: 0 ]
Avatar
Joined: 2010-01-29
32 posts

Ok, I see it clearly: http://www.overzealous.com/dmz/pages/deleteall.html
Thanks very much

 
Posted: 04 May 2010 08:03 AM   [ # 465 ]   [ Rating: 0 ]
Avatar
Joined: 2010-01-29
32 posts

Advanced Relationship

Hi all. I’m not able to understand how advanced relationships work.
I’ve read user guide and made tests, but I can’t understand how field names are used.

This is my sample case:
- table users(id, name)
- table quotes(id, client_id, worker_id)
- user model and quote model

One user (worker_id) can create a new quote for other user (client_id).
‘worker_id’ and ‘client_id’ are in fact ids from users table.

How should I make relationships? This is what I’ve done:

class Quote extends DataMapper {
  
var $has_many = array(
        
'client_id' => array('class' => 'user','other_field' => 'client'),
        
'worker_id' => array('class' => 'user','other_field' => 'worker')
  );
class User extends DataMapper {
  
var $has_one = array(
    
'client' => array('class' => 'quote''other_field' => 'client_id'),
    
'worker' => array('class' => 'quote''other_field' => 'worker_id')
  );

Is that right? And from my controller, how should I populate this? I want to get something like this:

<?php
$q 
= new Quote($id);

$q->client->get();
echo 
$q->client->name;

$q->worker->get();
echo 
$q->worker->name;
?> 

Please, help me understanding this relationships.
Thanks all

 
Posted: 04 May 2010 08:52 AM   [ # 466 ]   [ Rating: 0 ]
Avatar
Joined: 2008-10-08
1039 posts

@Wazzu

Please post in the new forum.  DMZ 1.6 has been deprecated for a while now.

You are more likely to get answers there.

 Signature 

Phil DeJarnett
  OverZealous Creations, LLC

 
Posted: 04 May 2010 12:32 PM   [ # 467 ]   [ Rating: 0 ]
Avatar
Joined: 2010-01-29
32 posts

Thanks, Phil.
I posted here because of the version I use.
I’ll post there anyway.

 
Posted: 19 August 2010 05:21 AM   [ # 468 ]   [ Rating: 0 ]
Joined: 2009-05-07
106 posts

sorry i posted it here the reply is here
http://ellislab.com/forums/viewthread/149388/P580/#789462

 
31 of 32
31