Re: filter data with controller or model?

2014-05-23 Thread Andrew Barry
I tell a lie, I had a plural model name so I fixed this and it works

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: filter data with controller or model?

2014-05-23 Thread Andrew Barry
Hi,

Didnt work sorry and I dont know how to fix this. You have to be careful 
with the single quotes placed here because they copy across. 

*Error: * SQLSTATE[42S22]: Column not found: 1054 Unknown column 
'Tutorsessions.teacher_id' in 'where 
clause'??  This col exists so I 
dont know what to do !


In my model I have this

public function findstuff($teacherId = null) {
if (!$teacherId) {
return array(); }

 return $this->find('all',
array('conditions' => array('Tutorsessions.teacher_id' => 
$teacherId)));
}

I my controller I have

public  function home2()
{
   
$teacherId=1;
$this->set('tutor',$this->Tutorsession->findstuff($teacherId));
}


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


RE: load 2 models in controller

2014-05-23 Thread Advantage+
Something along these lines perhaps:

Controller:

 

call this and it would set the retrieved data for the view for you.

$this->set('teachers', ClassRegistry::init('Teacher')->getTeachers($parms to 
get teachers if needed based on limit, conditions so forth, the Tutorsession 
id));

 

 

Teacher Model:

getTeachers()

would be a model function to get teachers based on any normal conditions, 
limit, id, so forth.

 

 

 

From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of 
Andrew Barry
Sent: Saturday, May 24, 2014 3:32 AM
To: cake-php@googlegroups.com
Subject: Re: load 2 models in controller

 

I need to know how this is done . ( My example was just that).
I just want to load another tables data in on the same view as another table 
data (just assume the data is not related).

 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: load 2 models in controller

2014-05-23 Thread Andrew Barry
I need to know how this is done . ( My example was just that).
I just want to load another tables data in on the same view as another 
table data (just assume the data is not related).


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: filter data with controller or model?

2014-05-23 Thread Jeremy Burns | Class Outfit
As a general rule, let the model do all the heavy lifting (fat models, thin 
controllers). It keeps the business logic in one place. What you have described 
below are two different things. The first is a find command called by the 
controller. The second is the code that associates this model with others. Both 
are important but do different things. The practice I adopt is to have methods 
within each model that accept parameters, do the finding and parsing and return 
a completed result. This can be called from another model or from a controller. 
For example, in the post model you might have a method:

public function findLatest($authorId = null, $limit = 3) {
if (!$authorId) {
return array();
}

return $this->find(
'all',
array(
'conditions' => array('Post.author.id => $authorId)
'order' => array('Post.created => 'desc'),
'limit' => $limit
)
);
}

Then from the post controller you can call:

$lastThreePosts = $this->Post->findLatest($authorId, 3);

Or from the Author model (assuming Author hasMany Post):

$latestPost = $this->Post->findLatest($authorId, 1);


On 24 May 2014, at 04:33, Andrew Barry  wrote:

> In cakephp what is the method to filter data on a database request.
> Do I filter the data from a model or a controller?
> 
> Say if I have a table with 1000's of rows and I only want to select rows on a 
> condition , like a where clause on sql.
> 
> The user enters in a certain fields to select rows from a table.
> 
> I then pass this variable to the controller and the controller filters this 
> data or is the model supposed to filter the rows selected?
> 
> I didnt quite see this clearly from the cakephp docs.
> I am not sure if a model or controller is the best way to go about it.
> 
> a controller would do ///
>  public function view($id = null) {
>   $post = $this->Post->findById($id);
> 
> 
> $this->set('post', $post);
> }
> 
> a model would do something like the below where you set the condition and 
> this seems a really messy way to go about things.
> 
> class Recipe extends AppModel {
> public $hasAndBelongsToMany = array(
> 'Ingredient' =>
> array(
> 'className' => 'Ingredient',
> 'joinTable' => 'ingredients_recipes',
> 'foreignKey' => 'recipe_id',
> 'associationForeignKey' => 'ingredient_id',
> 'unique' => true,
> 'conditions' => '',
> 'fields' => '',
> 'order' => '',
> 'limit' => '',
> 'offset' => '',
> 'finderQuery' => '',
> 'with' => ''
> )
> );
> }
> 
> 
> -- 
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


RE: load 2 models in controller

2014-05-23 Thread Advantage+
Why not use the standard relations?

 

One would think the Teacher hasManyTutorSession <-> TutorSession BelongsTo 
Teacher.

So when you get Teacher data you would get the TutorSession or vice versa. 

You get the TutorSession and that would have the Teacher data.

 

 

 

From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of 
Andrew Barry
Sent: Saturday, May 24, 2014 3:04 AM
To: cake-php@googlegroups.com
Subject: load 2 models in controller

 

Hi,

In my view I want to display data from 2 tables (maybe not related).
I read i do the following to load 2 model in a controller and simply access the 
other model in the view.

I get an error in the view file so this method of loading 2 models in a 
contrller doesnt work?

Undefined index: Teacher



class TutorsessionsController extends AppController
{

//do I need to add anything here like public $uses?

public  function index()
{
   $this->set('tutor',$this->Tutorsession->find('all')); 
 
   
   $this->loadModel('Teacher');
$this->set('teacher', $this->Teacher->find('all'));
}

in View

.
  foreach ($teacher as $item): 
echo ''. $item['Teacher']['id']. '';

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


load 2 models in controller

2014-05-23 Thread Andrew Barry
Hi,

In my view I want to display data from 2 tables (maybe not related).
I read i do the following to load 2 model in a controller and simply access 
the other model in the view.

I get an error in the view file so this method of loading 2 models in a 
contrller doesnt work?

Undefined index: Teacher



class TutorsessionsController extends AppController
{

//do I need to add anything here like public $uses?

public  function index()
{
   $this->set('tutor',$this->Tutorsession->find('all')); 
 
   
   $this->loadModel('Teacher');
$this->set('teacher', $this->Teacher->find('all'));
}

in View

.
  foreach ($teacher as $item): 
echo ''. $item['Teacher']['id']. '';

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


filter data with controller or model?

2014-05-23 Thread Andrew Barry
In cakephp what is the method to filter data on a database request.
Do I filter the data from a model or a controller?

Say if I have a table with 1000's of rows and I only want to select rows on 
a condition , like a where clause on sql.

The user enters in a certain fields to select rows from a table.

I then pass this variable to the controller and the controller filters this 
data or is the model supposed to filter the rows selected?

I didnt quite see this clearly from the cakephp docs.
I am not sure if a model or controller is the best way to go about it.

a controller would do ///
 public function view($id = null) {
  $post = $this->Post->findById($id);


$this->set('post', $post);
}

a model would do something like the below where you set the condition and this 
seems a really messy way to go about things.

class Recipe extends AppModel {
public $hasAndBelongsToMany = array(
'Ingredient' =>
array(
'className' => 'Ingredient',
'joinTable' => 'ingredients_recipes',
'foreignKey' => 'recipe_id',
'associationForeignKey' => 'ingredient_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'with' => ''
)
);
}


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Fatal error: Out of memory (allocated 10485760)

2014-05-23 Thread 'Chris' via CakePHP
hi guys,... 
why am I getting this error from time to time,...? 
*Fatal error*: Out of memory (allocated 10485760) (tried to allocate 19456 
bytes) in
thanks 
Chris

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Router and paginator

2014-05-23 Thread HK
I have in my routes.php:

Router::connect('/articles/translated', array('controller' => 'articles', 
> 'action' => 'translated', true));
> Router::connect('/articles/nontranslated', array('controller' => 
> 'articles', 'action' => 'translated', false));
>

So in articles controller I have:

function translated($isTranslated) {
>   $this->Paginator->settings = Hash::merge($this->paginate, array(
> 'conditions' => array('isTranslated' => $isTranslated)
> ));
> }
>

it works well except paginator helper. In /articles/nontranslated the page 
links appear as:
/articles/translated/page:2 while I would like to appear as
/articles/nontranslated/page:2 or 
/articles/translated/false/page:2

In my view I have:
$this->Paginator->options(array('url' => $this->passedArgs));

any help with this?

Thanks


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: displaying 2 tables

2014-05-23 Thread Andrew Townsley
Hi,

My error is now the view and controller where I link the 2 tables.


I have ended up with the problem with this line in the controller with the 
models having the reference to another table

Undefined variable: posts [*APP\View\Posts\home2.ctp*, line *11*]


public  function home2()
{
   
 $this->Post->find('all', array('contain' => array('User')));
}

in the view I get an error
foreach ($posts as $item):  ..
Undefined variable: posts 



-- 
 
*P: (03) 9866 7737*
*E: i...@itfutures.edu.au *
*A: Suite 5 / Level 1 / 424 St Kilda Rd, Melbourne, 3004 
*


-- 
*Connect with us: *

 

     


-- 


Please consider the environment before printing this email.

 

This e-mail and any attachments to it (the "Communication") is, unless 
otherwise stated, confidential,  may contain copyright material and is for 
the use only of the intended recipient. If you receive the Communication in 
error, please notify the sender immediately by return e-mail, delete the 
Communication and the return e-mail, and do not read, copy, retransmit or 
otherwise deal with it. Any views expressed in the Communication are those 
of the individual sender only, unless expressly stated to be those of 
National Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any 
of its related entities. NTSP does not accept liability in connection with 
the integrity of or errors in the Communication, computer virus, data 
corruption, interference or delay arising from or in respect of the 
Communication.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: displaying 2 tables

2014-05-23 Thread Stephen S
Hey that looks correct to me, I probably should have been more specific
over recursive.

By default recursive is switched on, which means when you query a specific
model, it will find associated tables along with it (up to 1 level I
believe), you can change recursive to find more associated tables or none
at all. I find it best practice to turn this off immediately as I like to
specify which models and fields should be queried to be more efficient.

http://book.cakephp.org/2.0/en/models/model-attributes.html#recursive

I do this by adding public $recursive = -1; in my AppModel.php file.

This brings us to contain which is what you should use when you want to
find associated tables in your query (if recursive isn't switched off you
may not need to do this), I forgot to mention you'll likely need to enable
this behaviour (I do this in AppModel).

http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html#containable


On 22 May 2014 23:53, Andrew Townsley  wrote:

> Hi,
>
> OK you need to be a bit more specific as I am new to this.
>
> Say I have 2 tables table1 and table2 and each has its own model.
> table1 has a 1 to many relationship with table2.
>
> table1 has a id
> table2 has the same id as a foreign key.
>
>
> *In my table1 model*
>
> public $belongsTo = array('Table2');
>
> *In my table2 model*
>
> public $hasMany = array('Table1');
>
>
> *The query*
> $everything = $this->Table1->find('all', array('contain' =>
> array('Table2')));
> *// Assuming recursive is -1 in your AppModel* ??? where is
> this please
>
> *Then I can access the data from a view*
>
> foreach($everything as $data) {
> echo $user['Table1']['name'];
> echo $user['Table2'']['username'];
> }
>
> Is this correct?
>
>
> On Wednesday, May 21, 2014 7:30:24 PM UTC+10, Stephen S wrote:
>
>> Hey
>>
>> Name refers to the name of the model, you may also be interested in
>> $useTable = 'table_name' to specify a table name other than the plural of
>> your model name.
>>
>> As for referring to two database tables in one view, you don't
>> necessarily need to have two controllers for this but you should have two
>> models. Let assume you have a User model and a UserType model (Where the
>> users table has a field named user_type_id)
>>
>> *In your users model*
>>
>>
>>
>> public $belongsTo = array('UserType');
>>
>> *In your user type model*
>>
>> public $hasMany = array('User');
>>
>> *The query*$users = $this->User->find('all', array('contain' =>
>> array('UserType'))); *// Assuming recursive is -1 in your AppModel*
>>
>>
>> *Then you can access to the UserType like such*
>>
>> foreach($users as $user) {
>> echo $user['UserType']['name'];
>> echo $user['User']['username'];
>> }
>>
>> http://api.cakephp.org/2.5/source-class-Model.html#243-249
>> http://book.cakephp.org/2.0/en/models/associations-
>> linking-models-together.html
>>
>> Hope this helps
>>
>>
>> On 20 May 2014 23:56, Andrew Barry  wrote:
>>
>>> Hi,
>>> I have just started cakephp and got working an example.
>>>
>>> if you look at a hello world example from cakephp then I have these
>>> files.
>>> I have a table name called users and looking at the blog tutorial that
>>> name users should refer to a database name .
>>>
>>> q1)My example works but what is correct? Is the name 'users' a table or
>>> databasename?
>>>
>>> q2)How do I refer to 2 database tables in the 1 view as do I need
>>> another model and controller for every database table I access?
>>>
>>> http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/part-two.html
>>>
>>> >> class User extends AppModel
>>> {
>>> var $name='User';
>>> }
>>> ?>
>>>
>>> >> class UsersController extends AppController
>>> {
>>> var $name='Users';
>>> function index()
>>> {
>>> }
>>> }
>>> ?>
>>>
>>> 
>>>
>>> >>
>>> /*http://127.0.0.1/cakephp/users/*/
>>> echo "Hello World";
>>> ?>
>>> 
>>>
>>>  --
>>> Like Us on FaceBook https://www.facebook.com/CakePHP
>>> Find us on Twitter http://twitter.com/CakePHP
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "CakePHP" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to cake-php+u...@googlegroups.com.
>>> To post to this group, send email to cake...@googlegroups.com.
>>>
>>> Visit this group at http://groups.google.com/group/cake-php.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Kind Regards
>>  Stephen Speakman
>>
>
>  
> *P: (03) 9866 7737*
> *E: i...@itfutures.edu.au *
> *A: Suite 5 / Level 1 / 424 St Kilda Rd, Melbourne, 3004
> 

Re: Search Plugin Problem (?)

2014-05-23 Thread Hungle
What is your db table look like?
Could you post the SQL here?


On Thu, May 22, 2014 at 9:51 PM, 山本広樹  wrote:

>
> Model-
>
>  App::uses('AppModel','Model');
>
> class DetailData extends AppModel{
>
> public $actsAs = array('Search.Searchable');
> public $filterArgs = array('school_name'=> array('type' => 'value'),);
>
>
> }
>
>
> Controller-
>
>  App::uses('AppController', 'Controller');
>
> class DetailDatasController extends AppController {
>
> public $components = array('Paginator','Search.Prg');
>
>  public function beforeFilter(){
>
> parent::beforeFilter();
>
> }
>
>  public function index(){
>
> $this->Prg->commonProcess();
> $this->paginate = array(
> 'DetailData' =>
> array(
> 'conditions' => array(
> $this->DetailData->parseCriteria($this->passedArgs)
> )
> ));
>
> $this->DetailData->recursive = 0;
> $this->set('detaildatas', $this->Paginator->paginate());
>
> }
>
> }
>
> View---
> 
> 
> 
> 
> 
>
> 
> 
> 
> 
>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>
> 
> echo $this->Paginator->counter(array('format' => '全%count%件' ));
> echo $this->Paginator->counter(array('format' =>
> '{:page}/{:pages}ページを表示'));
>
> echo $this->Paginator->first('最初のページへ ', array(), null,
> array('class'=> 'first disabled'));
> echo $this->Paginator->prev(' < 前へ',array(), null, array('class' =>
> 'prev disabled'));
> echo $this->Paginator->numbers(array('separator' => ' '));
> echo $this->Paginator->next(' 次へ >', array(), null, array('class'=>
> 'next disabled'));
> echo $this->Paginator->last(' 最後のページへ', array(), null, array('class'=>
> 'next disabled'));
> ?>
>
> 
> element('searchForm'); ?>
>
>
> 
> 
>
>
> Error-
> Database Error
> *Error: *SQLSTATE[42000]: Syntax error or access violation: 1064 You have
> an error in your SQL syntax; check the manual that corresponds to your
> MySQL server version for the right syntax to use near 'parseCriteria' at
> line 1
> 
>
> It doesn't work. Plugin is Cake DC/Search.
>
> Do you have any idea to solve this problem?
>
>
>
> Hiroki Yamamoto
>
>
>
>
>  --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Autologin in cakePHP 2.5

2014-05-23 Thread tk
Hi,

All you need for login is the user information. Try to read the user by 
your ID from database and then use this result for login.

$user = $this->User->findById( $userID );
$this->Auth->login( $user );

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Fatal Error: Undefined variable: before [APP/Plugin/DebugKit/Controller/Component/ToolbarComponent.php, line 194]

2014-05-23 Thread Deb Vorndran
The DebugKit ToolbarComponent is giving me a fatal error, 
when I set

 Configure::write('debug', 2);

in APP/Config/core.php

I'm on PHP version 5.5.12, on my server.
Locally, I'm on PHP version 5.5.9, with no problems.

---
I am able to workaround the problem by "skipping" the function causing the 
problem  in the file:

  app/Plugin/DebugKit/Controller/Component/ToolbarComponent.php

as follows:

public function implementedEvents() {
return array();
}




Does anyone have a better solution?

Thx!
:-D




-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Search Plugin Problem (?)

2014-05-23 Thread 山本広樹
Model-

 array('type' => 'value'),);


}

Controller-

Prg->commonProcess();
$this->paginate = array(
'DetailData' =>
array(
'conditions' => array(
$this->DetailData->parseCriteria($this->passedArgs)
)
));

$this->DetailData->recursive = 0; 
$this->set('detaildatas', $this->Paginator->paginate());

}

}

View---























Paginator->counter(array('format' => '全%count%件' ));
echo $this->Paginator->counter(array('format' => 
'{:page}/{:pages}ページを表示'));

echo $this->Paginator->first('最初のページへ ', array(), null, array('class'=> 
'first disabled'));
echo $this->Paginator->prev(' < 前へ',array(), null, array('class' => 
'prev disabled'));
echo $this->Paginator->numbers(array('separator' => ' '));
echo $this->Paginator->next(' 次へ >', array(), null, array('class'=> 
'next disabled'));
echo $this->Paginator->last(' 最後のページへ', array(), null, array('class'=> 
'next disabled'));
?>


element('searchForm'); ?>





Error-
Database Error
*Error: *SQLSTATE[42000]: Syntax error or access violation: 1064 You have 
an error in your SQL syntax; check the manual that corresponds to your 
MySQL server version for the right syntax to use near 'parseCriteria' at 
line 1


It doesn't work. Plugin is Cake DC/Search.

Do you have any idea to solve this problem?



Hiroki Yamamoto




-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


2 tables wont display

2014-05-23 Thread Andrew Townsley
I am getting an error on a simple display of 2 tables as i am just learning 
it.
I know sql but cakephp is awkward with sql/

Anyway I have

*Error: * SQLSTATE[42S22]: Column not found: 1054 Unknown column 
'Post.user_id' in 'on clause'

*SQL Query: * SELECT `Post`.`id`, `Post`.`title`, `Post`.`body`, 
`Post`.`created`, `Post`.`modified`, `User`.`two`, `User`.`three`, 
`User`.`id` FROM `jagguy`.`posts` AS `Post` LEFT JOIN `jagguy`.`users` AS 
`User` ON (`Post`.`user_id` = `User`.`id`) WHERE 1 = 1 

models ( I have 2 tables with 1 files with id in common

class Post extends AppModel
{
/*var $name='User';*/
public $belongsTo = array('User');
}

class User extends AppModel
{
public $hasMany = 'Post';
}


class PostsController extends AppController
{

public  function home2()
{
   
$everything=  $this->Post->find('all', array('contain' => 
array('User')));
} 


view



 '. $item['Post']['id']. '';
echo ''. $item['Post']['title'].'';
   echo ''. $item['Post']['body'].'';




-- 
 
*P: (03) 9866 7737*
*E: i...@itfutures.edu.au *
*A: Suite 5 / Level 1 / 424 St Kilda Rd, Melbourne, 3004 
*


-- 
*Connect with us: *

 

     


-- 


Please consider the environment before printing this email.

 

This e-mail and any attachments to it (the "Communication") is, unless 
otherwise stated, confidential,  may contain copyright material and is for 
the use only of the intended recipient. If you receive the Communication in 
error, please notify the sender immediately by return e-mail, delete the 
Communication and the return e-mail, and do not read, copy, retransmit or 
otherwise deal with it. Any views expressed in the Communication are those 
of the individual sender only, unless expressly stated to be those of 
National Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any 
of its related entities. NTSP does not accept liability in connection with 
the integrity of or errors in the Communication, computer virus, data 
corruption, interference or delay arising from or in respect of the 
Communication.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: displaying 2 tables

2014-05-23 Thread Andrew Townsley
Hi,

OK you need to be a bit more specific as I am new to this.

Say I have 2 tables table1 and table2 and each has its own model. 
table1 has a 1 to many relationship with table2.

table1 has a id
table2 has the same id as a foreign key.


*In my table1 model*

public $belongsTo = array('Table2');

*In my table2 model*

public $hasMany = array('Table1');


*The query*
$everything = $this->Table1->find('all', array('contain' => 
array('Table2'))); 
*// Assuming recursive is -1 in your AppModel* ??? where is 
this please

*Then I can access the data from a view*

foreach($everything as $data) {
echo $user['Table1']['name'];
echo $user['Table2'']['username'];
}

Is this correct?

On Wednesday, May 21, 2014 7:30:24 PM UTC+10, Stephen S wrote:
>
> Hey
>
> Name refers to the name of the model, you may also be interested in 
> $useTable = 'table_name' to specify a table name other than the plural of 
> your model name.
>
> As for referring to two database tables in one view, you don't necessarily 
> need to have two controllers for this but you should have two models. Let 
> assume you have a User model and a UserType model (Where the users table 
> has a field named user_type_id)
>
> *In your users model*
>
>
>
> public $belongsTo = array('UserType');
>
> *In your user type model*
>
> public $hasMany = array('User');
>
> *The query*$users = $this->User->find('all', array('contain' => 
> array('UserType'))); *// Assuming recursive is -1 in your AppModel*
>
> *Then you can access to the UserType like such*
>
> foreach($users as $user) {
> echo $user['UserType']['name'];
> echo $user['User']['username'];
> }
>
> http://api.cakephp.org/2.5/source-class-Model.html#243-249
>
> http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html
>
> Hope this helps
>
>
> On 20 May 2014 23:56, Andrew Barry >wrote:
>
>> Hi,
>> I have just started cakephp and got working an example.
>>
>> if you look at a hello world example from cakephp then I have these files.
>> I have a table name called users and looking at the blog tutorial that 
>> name users should refer to a database name .
>>
>> q1)My example works but what is correct? Is the name 'users' a table or 
>> databasename?
>>
>> q2)How do I refer to 2 database tables in the 1 view as do I need another 
>> model and controller for every database table I access?
>>
>> http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/part-two.html
>>
>> > class User extends AppModel
>> {
>> var $name='User';
>> }
>> ?>
>>
>> > class UsersController extends AppController
>> {
>> var $name='Users';
>> function index()
>> {
>> }
>> }
>> ?>
>>
>> 
>>
>> >
>> /*http://127.0.0.1/cakephp/users/*/
>> echo "Hello World";
>> ?>
>> 
>>
>>  -- 
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to cake-php+u...@googlegroups.com .
>> To post to this group, send email to cake...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/cake-php.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Kind Regards
>  Stephen Speakman
>  

-- 
 
*P: (03) 9866 7737*
*E: i...@itfutures.edu.au *
*A: Suite 5 / Level 1 / 424 St Kilda Rd, Melbourne, 3004 
*


-- 
*Connect with us: *

 

     


-- 


Please consider the environment before printing this email.

 

This e-mail and any attachments to it (the "Communication") is, unless 
otherwise stated, confidential,  may contain copyright material and is for 
the use only of the intended recipient. If you receive the Communication in 
error, please notify the sender immediately by return e-mail, delete the 
Communication and the return e-mail, and do not read, copy, retransmit or 
otherwise deal with it. Any views expressed in the Communication are those 
of the individual sender only, unless expressly stated to be those of 
National Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any 
of its related entities. NTSP does not accept liability in connection with 
the integrity of or errors in the Communication, computer virus, data 
corruption, interference or delay arisi