Part of the EllisLab Network
   
47 of 47
47
[Deprecated] DMZ 1.6.2 (DataMapper OverZealous Edition)
Posted: 13 April 2010 01:19 AM   [ Ignore ]   [ # 461 ]  
Grad Student
Rank
Total Posts:  59
Joined  09-20-2008

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

 Signature 

Sorry for my pour english [2] :(

Profile
 
 
Posted: 02 May 2010 12:28 PM   [ Ignore ]   [ # 462 ]  
Grad Student
Avatar
Rank
Total Posts:  33
Joined  01-29-2010

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(); 
Profile
 
 
Posted: 02 May 2010 10:15 PM   [ Ignore ]   [ # 463 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1041
Joined  10-08-2008

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

Profile
 
 
Posted: 03 May 2010 02:09 AM   [ Ignore ]   [ # 464 ]  
Grad Student
Avatar
Rank
Total Posts:  33
Joined  01-29-2010

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

Profile
 
 
Posted: 04 May 2010 07:03 AM   [ Ignore ]   [ # 465 ]  
Grad Student
Avatar
Rank
Total Posts:  33
Joined  01-29-2010

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

Profile
 
 
Posted: 04 May 2010 07:52 AM   [ Ignore ]   [ # 466 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1041
Joined  10-08-2008

@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

Profile
 
 
Posted: 04 May 2010 11:32 AM   [ Ignore ]   [ # 467 ]  
Grad Student
Avatar
Rank
Total Posts:  33
Joined  01-29-2010

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

Profile
 
 
Posted: 19 August 2010 04:21 AM   [ Ignore ]   [ # 468 ]  
Lab Assistant
RankRank
Total Posts:  105
Joined  05-07-2009

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

Profile
 
 
   
47 of 47
47