Re: loadModel

2012-08-29 Thread Mancho
Ok, your IndexsController has view() method? If not exists you need create
the  view() method in the IndexsController and in this method set the vars.

--
Murgan, Alexis Germán
Desarrollador & Diseñador
Web: german.murgan.com.ar
Email: ger...@murgan.com.ar
MSN: ger...@murgan.com.ar
Móvil: +5493424663813

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: loadModel

2012-08-29 Thread Nareh Tarasyan

Thanks people.
I tried all, but none helps.That variables work in index.ctp, but not in 
view :/

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: loadModel

2012-08-29 Thread Mancho
You never set to view file te $game and $word vars. Add to end of
index()method this:
$this->set('game', $game);
$this->set('word', $word);

I recommend you read the following:
http://book.cakephp.org/2.0/en/getting-started.html#blog-tutorial

--
Murgan, Alexis Germán
Desarrollador & Diseñador
Web: german.murgan.com.ar
Email: ger...@murgan.com.ar
MSN: ger...@murgan.com.ar
Móvil: +5493424663813

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: loadModel

2012-08-29 Thread Lucas Simon Rodrigues Magalhaes
And ...
$this->set(compact('games'));

Em quarta-feira, 29 de agosto de 2012 08h40min58s UTC-3, Lucas Simon 
Rodrigues Magalhaes escreveu:
>
> change this variable  $game = $this->Game->find('all'); 
> to
> $games =  = $this->Game->find('all');  
>
> in  IndexsController .
>
>
> Em quarta-feira, 29 de agosto de 2012 05h08min00s UTC-3, Nareh Tarasyan 
> escreveu:
>>
>> Hi people.
>> I'm a beginner in CakePHP.
>> And I need help. 
>>
>> I try to use loadModel.
>>
>> I have two models: games and words.
>>
>> In db have two tables: games(where I keep game difficulty levels) and 
>> words(where I keep words that I use in my game).
>>
>> Now I created IndexsController, where I load two models.
>> Here is how I do it:
>>
>> >
>> class IndexsController extends AppController {
>> public $helpers = array('Html', 'Form', 'Session');
>> public $components = array('Session');
>>
>>
>> public function index() {
>> $this->loadModel('Game');
>> $game = $this->Game->find('all');
>> $this->set('games', $this->Game->find('all'));
>>
>>
>> $this->loadModel('Word');
>> $word = $this->Word->find('all');
>> $this->set('words', $this->Word->find('all'));
>> }
>> }
>> ?>
>>
>> In View/Indexs I keep two files: index and view.
>> Here are they:
>>
>> index.ctp
>>
>> 
>>
>> 
>> 
>> Difficulty
>> 
>>
>> 
>>
>> 
>> 
>> 
>> Html->link($game['Game']['difficulty'], array('action' 
>> => 'view', $game['Game']['id'])); ?>
>> 
>>
>> 
>> 
>>
>> 
>> 
>>
>>
>> and view.ctp:
>> 
>> > .($game['Game']['difficulty']); ?>
>> 
>>
>>
>> Index.ctp works perfect, but in view.ctp it says:
>>
>> Undefined variable: game [APP\View\Indexs\view.ctp, line 9]
>>
>> What should I do???
>>
>> THanks everybody [image: smile.gif] 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: loadModel

2012-08-29 Thread Lucas Simon Rodrigues Magalhaes
change this variable  $game = $this->Game->find('all'); 
to
$games =  = $this->Game->find('all');  

in  IndexsController .


Em quarta-feira, 29 de agosto de 2012 05h08min00s UTC-3, Nareh Tarasyan 
escreveu:
>
> Hi people.
> I'm a beginner in CakePHP.
> And I need help. 
>
> I try to use loadModel.
>
> I have two models: games and words.
>
> In db have two tables: games(where I keep game difficulty levels) and 
> words(where I keep words that I use in my game).
>
> Now I created IndexsController, where I load two models.
> Here is how I do it:
>
> 
> class IndexsController extends AppController {
> public $helpers = array('Html', 'Form', 'Session');
> public $components = array('Session');
>
>
> public function index() {
> $this->loadModel('Game');
> $game = $this->Game->find('all');
> $this->set('games', $this->Game->find('all'));
>
>
> $this->loadModel('Word');
> $word = $this->Word->find('all');
> $this->set('words', $this->Word->find('all'));
> }
> }
> ?>
>
> In View/Indexs I keep two files: index and view.
> Here are they:
>
> index.ctp
>
> 
>
> 
> 
> Difficulty
> 
>
> 
>
> 
> 
> 
> Html->link($game['Game']['difficulty'], array('action' 
> => 'view', $game['Game']['id'])); ?>
> 
>
> 
> 
>
> 
> 
>
>
> and view.ctp:
> 
>  .($game['Game']['difficulty']); ?>
> 
>
>
> Index.ctp works perfect, but in view.ctp it says:
>
> Undefined variable: game [APP\View\Indexs\view.ctp, line 9]
>
> What should I do???
>
> THanks everybody [image: smile.gif] 
>

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: loadModel () returns empty

2012-07-18 Thread Ditshwanelo
i want to include the model in my controller,it was returning null nd now 
it gives internal server error..is sumthng wrong with my code??bt i tried 
to use var $uses=array('Listing'); it also gves me error.

On Wednesday, July 18, 2012 3:56:47 PM UTC+2, Ditshwanelo wrote:
>
> $this->loadModel('Listing');
>  $listing_query=$this->Listing->query("SELECT * FROM listing WHERE 
> listingstatus='Active' ");

-- 
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: loadModel () returns empty

2012-07-18 Thread euromark
also - when loading/including a model, why not using the wrapper methods 
cake gives you - for free one should mention


Am Mittwoch, 18. Juli 2012 16:22:16 UTC+2 schrieb AD7six:
>
> You've forgotten to ask a question..
>
> AD
>

-- 
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: loadModel () returns empty

2012-07-18 Thread AD7six
You've forgotten to ask a question..

AD

-- 
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: loadModel() and App::import('Model', 'ModelName')

2011-02-27 Thread Ryan Schmidt

On Feb 27, 2011, at 13:18, iainjames wrote:

> Hey guys, I'm having some trouble telling my controller actions which
> model to use. My controller is structed like so:
> ==
> class AdminController extends AppController {
>var $name = 'Admin';
>var $uses = array('News', 'User');
> 
>function action_that_uses_news_model() {
>}
> 
>function action_that_uses_user_model() {
>}
> ==
> 
> I'd like to ask how is it that I tell action_that_uses_user_model() to
> use the User model and not the News model.

Don't you just use $this->News->find() in the one action and 
$this->User->find() in the other one?



-- 
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: LoadModel on login form

2010-10-21 Thread cricket
On Wed, Oct 20, 2010 at 9:53 AM, IWC  wrote:
> I want my users to select a Depot at login so that I can use the
> selected Depot to filter reports and enquiries. I have been trying to
> use LoadModel to populate a select list on my login form but it never
> does.

Because you'd need query the DB to actually get the data. Loading the
model would only be the first step. But that's not a good way to do
this, anyway.

> How do I do this? Is there a better way to achieve the same
> thing.

In your controller:

$this->set(
'depots',
$this->YourModel->Depot->find('list')
);

Then use $depots in the view to populate your select list.

This is assuming that YourModel is associated with Depot and that the
table has a depot_id column ('YourModel.depot_id' key in the form).

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en


Re: loadModel function

2007-12-13 Thread lordG

This is interesting indeed...

As far as I could establish, I was not requesting the file to be
loaded twice. What is further interesting though is even if I did run
loadModel twice with the same instruction, the class_exists function
call within loadModel should have prevented this anyway.

Any ideas on this then?

Dr. Tarique Sani wrote:
> On 12/12/07, lordG <[EMAIL PROTECTED]> wrote:
> > Then, with the 1.2 branch release, does anyone know why in the
> > loadmodel function, they use require and not require_once? I've hit a
> > snack with this one, and change the require to require_once int he
> > code manually.
>
> Well, ideally require_once should never be needed if your program flow
> is correct ;) besides that require_once has a higher overhead than
> require. Still further you can always check if a given model is
> already available before calling loadmodel()
>
> Hope that helps
>
> Tarique
>
> --
> =
> Cheesecake-Photoblog: http://cheesecake-photoblog.org
> PHP for E-Biz: http://sanisoft.com
> =

--~--~-~--~~~---~--~~
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: loadModel function

2007-12-12 Thread Dr. Tarique Sani

On 12/12/07, lordG <[EMAIL PROTECTED]> wrote:
> Then, with the 1.2 branch release, does anyone know why in the
> loadmodel function, they use require and not require_once? I've hit a
> snack with this one, and change the require to require_once int he
> code manually.

Well, ideally require_once should never be needed if your program flow
is correct ;) besides that require_once has a higher overhead than
require. Still further you can always check if a given model is
already available before calling loadmodel()

Hope that helps

Tarique

-- 
=
Cheesecake-Photoblog: http://cheesecake-photoblog.org
PHP for E-Biz: http://sanisoft.com
=

--~--~-~--~~~---~--~~
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: loadModel( ) vs $uses

2007-02-13 Thread Grant Cox

Yes, that is correct.

On Feb 14, 1:12 am, "redhex" <[EMAIL PROTECTED]> wrote:
> Hi all, I am looking at reducing the size of my controller.
>
> Can I say that with loadModel, I can limit my $users array to the
> minimum? And for those methods that requires those less frequently
> uses model to load upon the different function request?


--~--~-~--~~~---~--~~
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: LoadModel - updating tutorials

2006-12-22 Thread salimk786


is this the right way ?
If this is the right way to use LoadMoel (see below code), then won't
the model be
re-instantiated each time the user types in an incorrect password?

//controller
function login()
   {
$this->pageTitle = "Login";
$this->set('pageImage', 'login-welcome.gif');
$arr_validation_errors = array();

$this->loadModel( 'Member' );
$this->Member = &new Member();

//render view if user is logged in
if($this->Authentication->_isLoggedin())
{
$this->redirect('/members/');
exit;
}

if (empty($this->params['data']))
{
$this->render();
}
else
{
//has password
$this->sanitize->cleanArray($this->params['data']);
$password = 
md5($this->params['data']['Member']['password']);

if ($this->Member->validates($this->params['data']))
{
$results = $this->Member->find("email_address =
'".$this->params['data']['Member']['email_address']."' AND password =
'". $password ."'",'Member.id,Member.fname');

if ($results['Member']['id'])
{
//sets up the session vars

$this->Authentication->set($results['Member']);
$this->Member->id = 
$results['Member']['id'];
$_POST = array();//make sure the post 
is cleared out
$this->redirect('/members/');
}
else
{
array_push($arr_validation_errors, 
"Please enter a correct email
address and/or password");

$this->params['data']['Member']['password'] = '';
$this->set('data', 
$this->params['data']);
$this->set('arr_validation_errors', 
$arr_validation_errors);
$this->validateErrors($this->Member);
}
}
else
{
$this->set('data', $this->params['data']);
$this->validateErrors($this->Member);
}
}
} //end function


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---