Re: Can I access database or execute some sql inside views ?

2007-08-14 Thread Wimg

one more question , how to pivot a table in controller?

change this table
a  b
1  2
3  4
5  6

to

c d f
1 3 5
2 4 6


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can I access database or execute some sql inside views ?

2007-08-14 Thread Wimg

how to pivot a table ?

change
a b
1 2
3 4
5 6

to

c d e
1 3 5
2 4 6
?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can I access database or execute some sql inside views ?

2007-08-14 Thread Wimg

really helps me a lot , thx


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can I access database or execute some sql inside views ?

2007-08-14 Thread fr3nch13

If you have your models setup correctly:

hasAndBelongsToMany if the user can be a part of many groups, or

User belongsTo Group | Group hasMany User if they only belong to one.

Then in the method your controller:
class GroupsController extends AppController
{
function index()
{
$this->Group->recursive = 2;
$this->set('groups', $this->Group->findAll()); // sets $groups 
for
your view to access it hint: in your view, look at pr($groups); i'll
bet you find your users
}
}


in View:


   

   
  
   




This isn't tested but it should give you a point in the right
direction


On Aug 14, 8:49 am, Wimg <[EMAIL PROTECTED]> wrote:
> The problem is like this, i have a database as below:
>
> user_id , group_id
>
> 1  1
> 2  1
> 3  2
> 4  2
>
> i wanna display users in the same group as a row in  a table
>
> group1  group2
> 12
> 34
>
> i was thinking that I get group_id first, then use group_ id to get
> users belong to the same group_id. but i donot know how to do this in
> controller .
>
> any ideas ? thx in front


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can I access database or execute some sql inside views ?

2007-08-14 Thread starkey

In your controller get the data and pivot it, then send it to the
view.

Shawn

On Aug 14, 8:49 am, Wimg <[EMAIL PROTECTED]> wrote:
> The problem is like this, i have a database as below:
>
> user_id , group_id
>
> 1  1
> 2  1
> 3  2
> 4  2
>
> i wanna display users in the same group as a row in  a table
>
> group1  group2
> 12
> 34
>
> i was thinking that I get group_id first, then use group_ id to get
> users belong to the same group_id. but i donot know how to do this in
> controller .
>
> any ideas ? thx in front


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can I access database or execute some sql inside views ?

2007-08-14 Thread Wimg

The problem is like this, i have a database as below:

user_id , group_id

1  1
2  1
3  2
4  2

i wanna display users in the same group as a row in  a table

group1  group2
12
34

i was thinking that I get group_id first, then use group_ id to get
users belong to the same group_id. but i donot know how to do this in
controller .

any ideas ? thx in front


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can I access database or execute some sql inside views ?

2007-08-14 Thread RichardAtHome

Post the problem and lets see if we can help you out :-)

On Aug 14, 10:29 am, Wimg <[EMAIL PROTECTED]> wrote:
> correct,, i just have a problem do not how to solve


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can I access database or execute some sql inside views ?

2007-08-14 Thread Wimg

correct,, i just have a problem do not how to solve

On Aug 14, 5:01 pm, Langdon Stevenson <[EMAIL PROTECTED]>
wrote:
>  > Can I access database or execute some sql inside views ?
>
> Given that this is PHP, yes I dare say you can.
>
> The point though is that you shouldn't.  Perform your queries and
> business logic in your Controller and Model.  Pass the resulting data to
> your view to render.  That is all that your view should be doing.
>
> If you really want to break this rule, then why use Cake?  You may as
> well just use vanilla PHP.
>
> Regards,
> Langdon


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can I access database or execute some sql inside views ?

2007-08-14 Thread Langdon Stevenson

 > Can I access database or execute some sql inside views ?

Given that this is PHP, yes I dare say you can.

The point though is that you shouldn't.  Perform your queries and 
business logic in your Controller and Model.  Pass the resulting data to 
your view to render.  That is all that your view should be doing.

If you really want to break this rule, then why use Cake?  You may as 
well just use vanilla PHP.

Regards,
Langdon

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---