Re: Select box broken after upgrade

2011-06-21 Thread madusanka hettiarachchi
hi Jeremy

I created relationship as u said and now select list displayed user's id
list.

I joined two tables called Album and User

Album has one User and User has many Albums
Album table has a field called user_id and it is foreign key of user
table,

here are my codes

::User Model:::

var $hasMany = array('Album');

::Album Model:

var $hasOne = array('User'= array(
 'className' = 'User',
 'foreignKey' = 'user_id',
 'dependent'= false
 ));

:::Album controller::

$users = $this-Album-User-find('list');
  $this-set(compact('users'));

:::view:::

echo $form-input('user_id', array('label' = 'Select User'));


when I run the code, it gives sql error like this,

 SELECT `Album`.`id`, `Album`.`album_name`, `Album`.`sub_directory`,
`Album`.`create_date`, `Album`.`last_modified_date`, `Album`.`music_id`,
`Album`.`album_category`, `Album`.`album_description`, `Album`.`user_id`,
`Album`.`size`, `User`.`id`, `User`.`user_name`, `User`.`user_password`,
`User`.`user_email`, `User`.`user_role`, `User`.`status`,
`User`.`temp_password` FROM `albums` AS `Album` LEFT JOIN `users` AS `User`
ON (`User`.`user_id` = `Album`.`id`)  WHERE 1 = 1

error occurred due to above  highlighted  sql part , It should be like this
(`Album`.`user_id` = `User`.`id`)
so where should i change the code to fix the error???

I kindly ask for quick response!


Ganganath Hettiarachchi

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Select box broken after upgrade

2011-06-21 Thread madusanka hettiarachchi
ok thanks guys I got correct it!


Ganganath Hettiarachchi

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Select box broken after upgrade

2011-06-20 Thread madusanka hettiarachchi
hi guys,


Hi CRUSH, Did you get solve your problem? I have same as you! I did the
changes which Jeremy said, bt It gives error like this,

Undefined property: Album::$Music
[*APP\controllers\albums_controller.php*, line *69*]
Code

function index(){//$lists =
$this-Album-Music-find('list',array('fields'=array('id','name')));
   $musicsList = $this-Album-Music-find('list');

AlbumsController::index() - APP\controllers\albums_controller.php, line 69
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 204
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171
[main] - APP\webroot\index.php, line 83


*Fatal error*: Call to a member function find() on a non-object in *
D:\xampp\htdocs\...\app\controllers\albums_controller.php* on line *69
*
here are my codes

view:::
echo $form-input('music_track_id', array('label' = 'Music Track'));

controller:::

$musicsList = $this-Album-Music-find('list'); //(line 69)
   $this-set(compact('musicsList'));

can any body help me?

Ganganath Hettiarachchi

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Select box broken after upgrade

2011-06-20 Thread CRUSH
Ganganath, I think your controller should be musics and your view
should be music_id

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Select box broken after upgrade

2011-06-20 Thread CRUSH
Jeremy,
Not working. I changed it to:

 Controller 
$mediaTypes = $this-Media-MediaType-find('list');
$this-set(compact('$mediaTypes'));

 View 
echo $this-Form-input('media_type_id');

and made the model change. Here is what it is outputting:
div class=input select
label for=MediaMediaTypeIdMedia Type/label
select name=data[Media][media_type_id] id=MediaMediaTypeId
/select
/div

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Select box broken after upgrade

2011-06-20 Thread madusanka hettiarachchi
hi CRUSH,
i ddnt get you clearly! can u explain it! u mean my controller class and
view class should be changed as u said???


Ganganath Hettiarachchi

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Select box broken after upgrade

2011-06-20 Thread CRUSH
view:::
echo $form-input('music_id', array('label' = 'Music Track'));

controller:::
$musics = $this-Album-Music-find('list');
$this-set(compact('musics'));

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Select box broken after upgrade

2011-06-20 Thread Jeremy Burns | Class Outfit
You have added a $ before the variable name in the compact statement. Remove it 
and replace it with exactly what I sent you.

On 20 Jun 2011, at 07:27, CRUSH wrote:

 Jeremy,
 Not working. I changed it to:
 
  Controller 
 $mediaTypes = $this-Media-MediaType-find('list');
 $this-set(compact('$mediaTypes'));
 
  View 
 echo $this-Form-input('media_type_id');
 
 and made the model change. Here is what it is outputting:
 div class=input select
 label for=MediaMediaTypeIdMedia Type/label
 select name=data[Media][media_type_id] id=MediaMediaTypeId
 /select
 /div
 
 -- 
 Our newest site for the community: CakePHP Video Tutorials 
 http://tv.cakephp.org 
 Check out the new CakePHP Questions site http://ask.cakephp.org and help 
 others with their CakePHP related questions.
 
 
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
 http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Select box broken after upgrade

2011-06-20 Thread madusanka hettiarachchi
Hi CRUSH, or other guys,

I want to know can I call a model from another model, like this!

$musics = $this-Album-Music-find('list');

It cause to error!

when execute a without giving Music model, it gives list of album ids.
$musics = $this-Album-Music-find('list');

what are the other thing i should do to call one model from another??

Ganganath Hettiarachchi

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Select box broken after upgrade

2011-06-20 Thread Jeremy Burns | Class Outfit
Make sure your model associations are set up correctly. Your example will only 
work if there is a association between Album and Music ($hasOne, $hasMany, 
$belongsTo or $hasAndBelongsToMany). If the models aren't directly related or 
there are models in between, you can daisy chain the models until you get where 
you want to be.

Here's a made up example: 
$musics = $this-Album-Artist-Singer-Music-find('list');


On 20 Jun 2011, at 12:29, madusanka hettiarachchi wrote:

 Hi CRUSH, or other guys,
 
 I want to know can I call a model from another model, like this!
 
 $musics = $this-Album-Music-find('list');
 
 It cause to error! 
 
 when execute a without giving Music model, it gives list of album ids.
 $musics = $this-Album-Music-find('list');
 
 what are the other thing i should do to call one model from another??
 
 Ganganath Hettiarachchi
 
 
 -- 
 Our newest site for the community: CakePHP Video Tutorials 
 http://tv.cakephp.org 
 Check out the new CakePHP Questions site http://ask.cakephp.org and help 
 others with their CakePHP related questions.
  
  
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
 http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Select box broken after upgrade

2011-06-20 Thread andy_the ultimate baker
u should check the relation of album and music

and while $this-set(compact('musicsList'));
use this
$this-set(compact('musicsList', $musicsList));

and u will collect them in ur view

Regards

Anand

On Jun 20, 11:07 am, madusanka hettiarachchi chamikara...@gmail.com
wrote:
 hi guys,

 Hi CRUSH, Did you get solve your problem? I have same as you! I did the
 changes which Jeremy said, bt It gives error like this,

 Undefined property: Album::$Music
 [*APP\controllers\albums_controller.php*, line *69*]
 Code

         function index(){                //$lists =
 $this-Album-Music-find('list',array('fields'=array('id','name')));
                $musicsList = $this-Album-Music-find('list');

 AlbumsController::index() - APP\controllers\albums_controller.php, line 69
 Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 204
 Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171
 [main] - APP\webroot\index.php, line 83

 *Fatal error*: Call to a member function find() on a non-object in *
 D:\xampp\htdocs\...\app\controllers\albums_controller.php* on line *69
 *
 here are my codes

 view:::
 echo $form-input('music_track_id', array('label' = 'Music Track'));

 controller:::

 $musicsList = $this-Album-Music-find('list'); //(line 69)
                    $this-set(compact('musicsList'));

 can any body help me?

 Ganganath Hettiarachchi

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Select box broken after upgrade

2011-06-20 Thread Jeremy Burns | Class Outfit
I don't think that's correct. The compact function looks for local variables 
and compacts them into variables that are sent to the view. So 
$this-set(compact('musicList')); is sufficient so long as $musicList exists 
when called. The idea of using compact is that you can send lots of variables 
through in a single statement: $this-set(compact('one', 'two', 'three')); 
would produce view variables $one, $two and $three (assuming they existed in 
the controller function). You can use: $this-set('musicList', $musicList); 
instead (i.e. with compact()) to send a single variable through. You'd need to 
repeat it for each variable though.

On 20 Jun 2011, at 07:12, andy_the ultimate baker wrote:

 u should check the relation of album and music
 
 and while $this-set(compact('musicsList'));
 use this
 $this-set(compact('musicsList', $musicsList));
 
 and u will collect them in ur view
 
 Regards
 
 Anand
 
 On Jun 20, 11:07 am, madusanka hettiarachchi chamikara...@gmail.com
 wrote:
 hi guys,
 
 Hi CRUSH, Did you get solve your problem? I have same as you! I did the
 changes which Jeremy said, bt It gives error like this,
 
 Undefined property: Album::$Music
 [*APP\controllers\albums_controller.php*, line *69*]
 Code
 
 function index(){//$lists =
 $this-Album-Music-find('list',array('fields'=array('id','name')));
$musicsList = $this-Album-Music-find('list');
 
 AlbumsController::index() - APP\controllers\albums_controller.php, line 69
 Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 204
 Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171
 [main] - APP\webroot\index.php, line 83
 
 *Fatal error*: Call to a member function find() on a non-object in *
 D:\xampp\htdocs\...\app\controllers\albums_controller.php* on line *69
 *
 here are my codes
 
 view:::
 echo $form-input('music_track_id', array('label' = 'Music Track'));
 
 controller:::
 
 $musicsList = $this-Album-Music-find('list'); //(line 69)
$this-set(compact('musicsList'));
 
 can any body help me?
 
 Ganganath Hettiarachchi
 
 -- 
 Our newest site for the community: CakePHP Video Tutorials 
 http://tv.cakephp.org 
 Check out the new CakePHP Questions site http://ask.cakephp.org and help 
 others with their CakePHP related questions.
 
 
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
 http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Select box broken after upgrade

2011-06-20 Thread CRUSH
Thank you Jeremy. Removing the dollar sign fixed it. A stupid error on
my end. I never even noticed that it was there!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Select box broken after upgrade

2011-06-19 Thread CRUSH
Hey,
I have spent hours troubleshooting this stupid problem. Tried many
combinations of names. This code gave me a select box with the media
types in the view in version 1.2. In version 1.3 it gives me an empty
select box. By debugging the $media_types I can see that the Find
call is getting the correct rows but that's as far as I know how to
debug. Any thoughts?

 Controller 
$media_types = $this-Media-MediaType-find('list',
array('fields'=array('MediaType.id', 'MediaType.type')));
$this-set(compact('media_types'));

 View 
echo $form-input('media_type_id', array('label' = 'Media Type'));

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Select box broken after upgrade

2011-06-19 Thread Jeremy Burns | Class Outfit
The variable should be called $mediaTypes, so do 
$this-set(compact('mediaTypes')); instead.

Also, consider going to the MediaType model and setting var $displayField = 
'type'; - then you don't need to specify the fields in the find; a simple 
$mediaTypes = $this-Media-MediaType-find('list'); will do.

On 20 Jun 2011, at 06:16, CRUSH wrote:

 Hey,
 I have spent hours troubleshooting this stupid problem. Tried many
 combinations of names. This code gave me a select box with the media
 types in the view in version 1.2. In version 1.3 it gives me an empty
 select box. By debugging the $media_types I can see that the Find
 call is getting the correct rows but that's as far as I know how to
 debug. Any thoughts?
 
  Controller 
 $media_types = $this-Media-MediaType-find('list',
 array('fields'=array('MediaType.id', 'MediaType.type')));
 $this-set(compact('media_types'));
 
  View 
 echo $form-input('media_type_id', array('label' = 'Media Type'));
 
 -- 
 Our newest site for the community: CakePHP Video Tutorials 
 http://tv.cakephp.org 
 Check out the new CakePHP Questions site http://ask.cakephp.org and help 
 others with their CakePHP related questions.
 
 
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
 http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php