Wednesday, April 30, 2014

Re: 3.0 - How to print/debug from Controller like Cake 2.xx

debug is set to true by default. i did var_dump but nothing happens.


On Thu, May 1, 2014 at 12:37 AM, José Lorenzo <jose.zap@gmail.com> wrote:
Do you have debug set to `true` in app.php? What happens if you use var_dump instead?


On Wednesday, April 30, 2014 8:00:29 PM UTC+2, Bayezid Alam wrote:
I tried by pr/debug($this->request->data); pr/debug($article) but showing nothing


On Wed, Apr 30, 2014 at 11:51 PM, Md Bayezid Alam <bayezidece@gmail.com> wrote:
i tried but It's showing nothing.. Could you please let me know how can i get this? Thanks


On Wed, Apr 30, 2014 at 11:24 PM, euromark <dereuromark@gmail.com> wrote:
And what is your problem?
The function still exists and can be used the same way.


Am Mittwoch, 30. April 2014 16:27:00 UTC+2 schrieb Bayezid Alam:
Dear All,

Is there any way to print from Controller?

For example,

I have a form like 

<?php
    echo $this->Form->create($article);
    echo $this->Form->input('title');
    echo $this->Form->input('body', ['rows' => '3']);
    echo $this->Form->button(__('Save Articles'));
    echo $this->Form->end();
?>

I have function in controller

public function add(){
        $article = $this->Articles->newEntity($this->request->data);
        if($this->request->is('post')){
            if($this->Articles->save($article)){
                $this->Session->setFlash(__('Your article has been saved.'));
                return $this->redirect(['action' => 'index']);
            }
            $this->Session->setFlash(__('Unable to add your article.'));
        }
        
        $this->set(compact('article'));
    }

I want to check by printing via pr() /  dubug() from my add function like i can do from Cakephp 2.xx.

--
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+unsubscribe@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+unsubscribe@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+unsubscribe@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.

Integrating Jasper Reports into Cakephp

I have been doing some research about utilizing Jasper reporting for a new Cakephp project I'm about to start. Has anyone else actually done this?
 
Ideally I would like to be able to programattically run the generation of reports directly from Cakephp logic.

--
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+unsubscribe@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: How to retrieve data from anther table in one model

You're doing it all wrong so even if you get this to work you are exposing yourself to problems down the line.

First, each table should have its own model. Second, name your tables correctly if you can. If you can't for whatever reason, then place public $useTable = 'your_table_name'; at the top of the model (rather than public $useTable = false;). Third, link your models through table associations. Then you can daisy chain models. For example, $this->TableOne->TableTwo-find('all');

On 30 Apr 2014, at 05:44:22, gyrate360 <gyrate360@gmail.com> wrote:

> I wanna retrieve data from anther table in one model.
> case is like this:
> in a model,eg:StaticTable,I set $useTable as false;
> so in one function,I just wanna get data from some table.how can I manage
> it?
> Here is my code,but it doese't work.
> part of the code in app/Model/StaticTable.php:
> class StaticTable extends Model{
> public $useTable = false;
> protected $_tableName = '';
> public function get_some_data(){
> $this->_tableName = 'tb_server_info';
> $serverInfo = $this->find('all', array(
> 'conditions' => array('status'=>1),
> 'order'=>array('created_date'=>'asc')
> ));
> $this->_tableName = 'tb_platform_info';
> $platformInfo= $this->find('all', array(
> 'conditions' => array('status'=>1),
> 'order'=>array('created_date'=>'asc')
> ));
> return
> array('server_info'=>$serverInfo.'platform_info'=>$platformInfo);
> }
> }
>
>
>
> --
> View this message in context: http://cakephp.1045679.n5.nabble.com/How-to-retrieve-data-from-anther-table-in-one-model-tp5718071.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
> --
> 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+unsubscribe@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.




Jeremy Burns
Class Outfit

http://www.classoutfit.com

--
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+unsubscribe@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: CakePHP 3.x - Accesing relations

Can you open a ticket for that? I will investigate it

On Wednesday, April 30, 2014 11:54:30 AM UTC+2, Thomas von Hassel wrote:
This works:

$this->belongsTo('Plugin.Related', [
        'className' => 'Related',
        'foreignKey' => 'my_id']);

This does not:

$this->belongsTo('Authors', [        
'className' => 'Publishing.Authors',
'foreignKey' => 'authorid',        
'propertyName' => 'person'    
]);


In other words, where you need to use plugin syntax is switched in the docs (or vice versa)


/thomas



On 30 Apr 2014, at 11:16, José Lorenzo <jose.zap@gmail.com> wrote:

> Show the initialize method for your table. Most probably you have a relationship to a Normal table object and not the the correct class. One way to make sure is providing the full 'className' in the association options.
>
> On Wednesday, April 30, 2014 7:46:10 AM UTC+2, Thomas von Hassel wrote:
> Ok, auto correct messed that up.
>
> Custom finder methods like this one on the related table don't work either:
>
> public function findSome(Query $query, array $options) {
>
> }
>
> when calling:
>
> From inside the Table class:
>
> $this->Related->find('some');
>
>
> The finder method itself works when called like this:
>
> $related = TableRegistry::get('MyPlugin.Related');
> $related->find('some');
>
>
> When i debug $this->Related
>
> i get this:
>
> ########## DEBUG ##########
> object(Cake\ORM\Association\BelongsTo)
>
>
>
>
>
>
>
> On 29 Apr 2014, at 23:13, José Lorenzo <jose.zap@gmail.com> wrote:
>
> > Calling custom functions should work, if it does not it is either a bug or a configuration error on your side
> >
> > On Tuesday, April 29, 2014 10:38:10 PM UTC+2, Thomas von Hassel wrote:
> > aah, yes when i tried using customer finders it worked, but not calling arbitrary functions that are defined in the Table object.
> >
> > I guess the right way is to use custom finders for everything then ?
> >
> > /thomas
> >
> > On 29 Apr 2014, at 22:06, José Lorenzo <jose.zap@gmail.com> wrote:
> >
> >> You can do exactly the same in cake 3
> >>
> >> On Tuesday, April 29, 2014 9:21:18 PM UTC+2, Thomas von Hassel wrote:
> >> Hey
> >>
> >> In 2.x when in a Model class you could do something like
> >>
> >> $this->RelatedModel->find('all');
> >>
> >>
> >> What's the "right" way to access related tables in a Table class ?
> >>
> >>
> >> /thomas
> >>
> >>
> >> --
> >> 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+unsubscribe@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+unsubscribe@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+unsubscribe@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+unsubscribe@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: 3.0 - How to print/debug from Controller like Cake 2.xx

Do you have debug set to `true` in app.php? What happens if you use var_dump instead?

On Wednesday, April 30, 2014 8:00:29 PM UTC+2, Bayezid Alam wrote:
I tried by pr/debug($this->request->data); pr/debug($article) but showing nothing


On Wed, Apr 30, 2014 at 11:51 PM, Md Bayezid Alam <bayezidece@gmail.com> wrote:
i tried but It's showing nothing.. Could you please let me know how can i get this? Thanks


On Wed, Apr 30, 2014 at 11:24 PM, euromark <dereuromark@gmail.com> wrote:
And what is your problem?
The function still exists and can be used the same way.


Am Mittwoch, 30. April 2014 16:27:00 UTC+2 schrieb Bayezid Alam:
Dear All,

Is there any way to print from Controller?

For example,

I have a form like 

<?php
    echo $this->Form->create($article);
    echo $this->Form->input('title');
    echo $this->Form->input('body', ['rows' => '3']);
    echo $this->Form->button(__('Save Articles'));
    echo $this->Form->end();
?>

I have function in controller

public function add(){
        $article = $this->Articles->newEntity($this->request->data);
        if($this->request->is('post')){
            if($this->Articles->save($article)){
                $this->Session->setFlash(__('Your article has been saved.'));
                return $this->redirect(['action' => 'index']);
            }
            $this->Session->setFlash(__('Unable to add your article.'));
        }
        
        $this->set(compact('article'));
    }

I want to check by printing via pr() /  dubug() from my add function like i can do from Cakephp 2.xx.

--
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+unsubscribe@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+unsubscribe@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: 3.0 - How to print/debug from Controller like Cake 2.xx

I tried by pr/debug($this->request->data); pr/debug($article) but showing nothing


On Wed, Apr 30, 2014 at 11:51 PM, Md Bayezid Alam <bayezidece@gmail.com> wrote:
i tried but It's showing nothing.. Could you please let me know how can i get this? Thanks


On Wed, Apr 30, 2014 at 11:24 PM, euromark <dereuromark@gmail.com> wrote:
And what is your problem?
The function still exists and can be used the same way.


Am Mittwoch, 30. April 2014 16:27:00 UTC+2 schrieb Bayezid Alam:
Dear All,

Is there any way to print from Controller?

For example,

I have a form like 

<?php
    echo $this->Form->create($article);
    echo $this->Form->input('title');
    echo $this->Form->input('body', ['rows' => '3']);
    echo $this->Form->button(__('Save Articles'));
    echo $this->Form->end();
?>

I have function in controller

public function add(){
        $article = $this->Articles->newEntity($this->request->data);
        if($this->request->is('post')){
            if($this->Articles->save($article)){
                $this->Session->setFlash(__('Your article has been saved.'));
                return $this->redirect(['action' => 'index']);
            }
            $this->Session->setFlash(__('Unable to add your article.'));
        }
        
        $this->set(compact('article'));
    }

I want to check by printing via pr() /  dubug() from my add function like i can do from Cakephp 2.xx.

--
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+unsubscribe@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+unsubscribe@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: 3.0 - How to print/debug from Controller like Cake 2.xx

i tried but It's showing nothing.. Could you please let me know how can i get this? Thanks


On Wed, Apr 30, 2014 at 11:24 PM, euromark <dereuromark@gmail.com> wrote:
And what is your problem?
The function still exists and can be used the same way.


Am Mittwoch, 30. April 2014 16:27:00 UTC+2 schrieb Bayezid Alam:
Dear All,

Is there any way to print from Controller?

For example,

I have a form like 

<?php
    echo $this->Form->create($article);
    echo $this->Form->input('title');
    echo $this->Form->input('body', ['rows' => '3']);
    echo $this->Form->button(__('Save Articles'));
    echo $this->Form->end();
?>

I have function in controller

public function add(){
        $article = $this->Articles->newEntity($this->request->data);
        if($this->request->is('post')){
            if($this->Articles->save($article)){
                $this->Session->setFlash(__('Your article has been saved.'));
                return $this->redirect(['action' => 'index']);
            }
            $this->Session->setFlash(__('Unable to add your article.'));
        }
        
        $this->set(compact('article'));
    }

I want to check by printing via pr() /  dubug() from my add function like i can do from Cakephp 2.xx.

--
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+unsubscribe@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+unsubscribe@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: 3.0 - How to print/debug from Controller like Cake 2.xx

And what is your problem?
The function still exists and can be used the same way.


Am Mittwoch, 30. April 2014 16:27:00 UTC+2 schrieb Bayezid Alam:
Dear All,

Is there any way to print from Controller?

For example,

I have a form like 

<?php
    echo $this->Form->create($article);
    echo $this->Form->input('title');
    echo $this->Form->input('body', ['rows' => '3']);
    echo $this->Form->button(__('Save Articles'));
    echo $this->Form->end();
?>

I have function in controller

public function add(){
        $article = $this->Articles->newEntity($this->request->data);
        if($this->request->is('post')){
            if($this->Articles->save($article)){
                $this->Session->setFlash(__('Your article has been saved.'));
                return $this->redirect(['action' => 'index']);
            }
            $this->Session->setFlash(__('Unable to add your article.'));
        }
        
        $this->set(compact('article'));
    }

I want to check by printing via pr() /  dubug() from my add function like i can do from Cakephp 2.xx.

--
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+unsubscribe@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.

3.0 - How to print/debug from Controller like Cake 2.xx

Dear All,

Is there any way to print from Controller?

For example,

I have a form like 

<?php
    echo $this->Form->create($article);
    echo $this->Form->input('title');
    echo $this->Form->input('body', ['rows' => '3']);
    echo $this->Form->button(__('Save Articles'));
    echo $this->Form->end();
?>

I have function in controller

public function add(){
        $article = $this->Articles->newEntity($this->request->data);
        if($this->request->is('post')){
            if($this->Articles->save($article)){
                $this->Session->setFlash(__('Your article has been saved.'));
                return $this->redirect(['action' => 'index']);
            }
            $this->Session->setFlash(__('Unable to add your article.'));
        }
        
        $this->set(compact('article'));
    }

I want to check by printing via pr() /  dubug() from my add function like i can do from Cakephp 2.xx.

--
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+unsubscribe@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: CakePHP 3.x - Accesing relations

This works:

$this->belongsTo('Plugin.Related', [
'className' => 'Related',
'foreignKey' => 'my_id']);

This does not:

$this->belongsTo('Authors', [
'className' => 'Publishing.Authors',
'foreignKey' => 'authorid',
'propertyName' => 'person'
]);


In other words, where you need to use plugin syntax is switched in the docs (or vice versa)


/thomas



On 30 Apr 2014, at 11:16, José Lorenzo <jose.zap@gmail.com> wrote:

> Show the initialize method for your table. Most probably you have a relationship to a Normal table object and not the the correct class. One way to make sure is providing the full 'className' in the association options.
>
> On Wednesday, April 30, 2014 7:46:10 AM UTC+2, Thomas von Hassel wrote:
> Ok, auto correct messed that up.
>
> Custom finder methods like this one on the related table don't work either:
>
> public function findSome(Query $query, array $options) {
>
> }
>
> when calling:
>
> From inside the Table class:
>
> $this->Related->find('some');
>
>
> The finder method itself works when called like this:
>
> $related = TableRegistry::get('MyPlugin.Related');
> $related->find('some');
>
>
> When i debug $this->Related
>
> i get this:
>
> ########## DEBUG ##########
> object(Cake\ORM\Association\BelongsTo)
>
>
>
>
>
>
>
> On 29 Apr 2014, at 23:13, José Lorenzo <jose.zap@gmail.com> wrote:
>
> > Calling custom functions should work, if it does not it is either a bug or a configuration error on your side
> >
> > On Tuesday, April 29, 2014 10:38:10 PM UTC+2, Thomas von Hassel wrote:
> > aah, yes when i tried using customer finders it worked, but not calling arbitrary functions that are defined in the Table object.
> >
> > I guess the right way is to use custom finders for everything then ?
> >
> > /thomas
> >
> > On 29 Apr 2014, at 22:06, José Lorenzo <jose.zap@gmail.com> wrote:
> >
> >> You can do exactly the same in cake 3
> >>
> >> On Tuesday, April 29, 2014 9:21:18 PM UTC+2, Thomas von Hassel wrote:
> >> Hey
> >>
> >> In 2.x when in a Model class you could do something like
> >>
> >> $this->RelatedModel->find('all');
> >>
> >>
> >> What's the "right" way to access related tables in a Table class ?
> >>
> >>
> >> /thomas
> >>
> >>
> >> --
> >> 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+unsubscribe@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+unsubscribe@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+unsubscribe@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+unsubscribe@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: CakePHP 3.x - Accesing relations

Show the initialize method for your table. Most probably you have a relationship to a Normal table object and not the the correct class. One way to make sure is providing the full 'className' in the association options.

On Wednesday, April 30, 2014 7:46:10 AM UTC+2, Thomas von Hassel wrote:
Ok, auto correct messed that up.

Custom finder methods like this one on the related table don't work either:

public function findSome(Query $query, array $options) {

}

when calling:

From inside the Table class:

$this->Related->find('some');


The finder method itself works when called like this:

$related = TableRegistry::get('MyPlugin.Related');
$related->find('some');


When i debug $this->Related

i get this:

########## DEBUG ##########
object(Cake\ORM\Association\BelongsTo)







On 29 Apr 2014, at 23:13, José Lorenzo <jose.zap@gmail.com> wrote:

> Calling custom functions should work, if it does not it is either a bug or a configuration error on your side
>
> On Tuesday, April 29, 2014 10:38:10 PM UTC+2, Thomas von Hassel wrote:
> aah, yes when i tried using customer finders it worked, but not calling arbitrary functions that are defined in the Table object.
>
> I guess the right way is to use custom finders for everything then ?
>
> /thomas
>
> On 29 Apr 2014, at 22:06, José Lorenzo <jose.zap@gmail.com> wrote:
>
>> You can do exactly the same in cake 3
>>
>> On Tuesday, April 29, 2014 9:21:18 PM UTC+2, Thomas von Hassel wrote:
>> Hey
>>
>> In 2.x when in a Model class you could do something like
>>
>> $this->RelatedModel->find('all');
>>
>>
>> What's the "right" way to access related tables in a Table class ?
>>
>>
>> /thomas
>>
>>
>> --
>> 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+unsubscribe@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+unsubscribe@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+unsubscribe@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.

Tuesday, April 29, 2014

Re: CakePHP 3.x - Accesing relations

Ok, auto correct messed that up.

Custom finder methods like this one on the related table don't work either:

public function findSome(Query $query, array $options) {

}

when calling:

From inside the Table class:

$this->Related->find('some');


The finder method itself works when called like this:

$related = TableRegistry::get('MyPlugin.Related');
$related->find('some');


When i debug $this->Related

i get this:

########## DEBUG ##########
object(Cake\ORM\Association\BelongsTo)







On 29 Apr 2014, at 23:13, José Lorenzo <jose.zap@gmail.com> wrote:

> Calling custom functions should work, if it does not it is either a bug or a configuration error on your side
>
> On Tuesday, April 29, 2014 10:38:10 PM UTC+2, Thomas von Hassel wrote:
> aah, yes when i tried using customer finders it worked, but not calling arbitrary functions that are defined in the Table object.
>
> I guess the right way is to use custom finders for everything then ?
>
> /thomas
>
> On 29 Apr 2014, at 22:06, José Lorenzo <jose.zap@gmail.com> wrote:
>
>> You can do exactly the same in cake 3
>>
>> On Tuesday, April 29, 2014 9:21:18 PM UTC+2, Thomas von Hassel wrote:
>> Hey
>>
>> In 2.x when in a Model class you could do something like
>>
>> $this->RelatedModel->find('all');
>>
>>
>> What's the "right" way to access related tables in a Table class ?
>>
>>
>> /thomas
>>
>>
>> --
>> 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+unsubscribe@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+unsubscribe@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+unsubscribe@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.

How to retrieve data from anther table in one model

I wanna retrieve data from anther table in one model.
case is like this:
in a model,eg:StaticTable,I set $useTable as false;
so in one function,I just wanna get data from some table.how can I manage
it?
Here is my code,but it doese't work.
part of the code in app/Model/StaticTable.php:
class StaticTable extends Model{
public $useTable = false;
protected $_tableName = '';
public function get_some_data(){
$this->_tableName = 'tb_server_info';
$serverInfo = $this->find('all', array(
'conditions' => array('status'=>1),
'order'=>array('created_date'=>'asc')
));
$this->_tableName = 'tb_platform_info';
$platformInfo= $this->find('all', array(
'conditions' => array('status'=>1),
'order'=>array('created_date'=>'asc')
));
return
array('server_info'=>$serverInfo.'platform_info'=>$platformInfo);
}
}



--
View this message in context: http://cakephp.1045679.n5.nabble.com/How-to-retrieve-data-from-anther-table-in-one-model-tp5718071.html
Sent from the CakePHP mailing list archive at Nabble.com.

--
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+unsubscribe@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.

un

un

--
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+unsubscribe@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.

CakePHP 2.4.9 released

The CakePHP core team is happy to announce the immediate availability of 2.4.9[1]. This releases contain a bug fix related to the security fix in 2.4.8. A short list of changes you can expect in 2.4.9 are:

* FormHelper::postLink() now works correctly with SecurityComponent. In 2.4.8 a mistake was made that resulted in incorrect hashes being generated.

If you use `postLink()` and have upgraded to 2.4.8 it is recommended that you upgrade to 2.4.9 to avoid any potential issues. You can download a packaged release from github[2].

### Links

- [1] http://cakephp.org/changelogs/2.4.9
- [2] http://github.com/cakephp/cakephp/tags

--
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+unsubscribe@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: calling all scrape builders!

Can you provide me with more information? 

On Monday, April 28, 2014 5:11:43 PM UTC-4, Danni Herbertson wrote:
does anyone want to give me a quote for building me a scrape to get the data from a website please??

--
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+unsubscribe@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: Delete only users sites

Quite a few ways to go around it, for example you can create something like this in your Site model (or even App Model if using $this->alias)

public function belongsToUser($siteId = null, $userId = null) {
    $site = $this->find('count', array(
        'conditions' => array(
            'Site.id' => $siteId,
            'Site.user_id' => $userId
        )
    ));

    return ($site > 0) ? true : false;
}

Then from your controller you can do something like..

if(! $this->Site->belongsToUser($siteId, $this->Auth->user('id')) {
    $this->Session->setFlash(__('Sorry that site does not belong to you'));
    return $this->redirect($this->referer());
}


On 29 April 2014 11:08, Gerculy Robert <rgerculy@gmail.com> wrote:
Hi there,

I'm working on a traffic exchange site and since I'm very new I used this login script : http://miftyisbored.com/a-complete-login-and-authentication-application-tutorial-for-cakephp-2-3/
Everything works nicely. Based on that code I created a few pages ( Add site, List sites, delete sites)

My problem is that anyone can delete the websites.( I'm sure this goes with users - not tested yet )

public function delete($id = null) {
        if (!$id) {
            $this->Session->setFlash('Please provide a site id');
            $this->redirect(array('action'=>'index'));
        }

        $this->Site->id = $id;
        if (!$this->Site->exists()) {
            $this->Session->setFlash('Invalid site id provided');
            $this->redirect(array('action'=>'index'));
        }
        if ($this->Site->saveField('status', 0)) {
            $this->Session->setFlash(__('Site deleted'));
            $this->redirect(array('action' => 'index'));
        }
        $this->Session->setFlash(__('Site was not deleted'));
        $this->redirect(array('action' => 'index'));
}   

This is the code. I tried adding a condition but couldn't make it work.
 I also tried a very old solution :

if($this->Site->user = $this->Session->read('Auth.User.id')){

// code

}else{
    echo"die";
}
 
But another fail.


--
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+unsubscribe@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.



--
Kind Regards
 Stephen Speakman

--
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+unsubscribe@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.

Cakephp and HasMany not returning association

I have started to play around with 3.0.  I have taken one of our models from 2.x and moving to 3.0 for practice and testing.     I have come across and issue when calling a Model/Table and attempting to include an hasMany association.   But, even though I use contain in the call it does add the association to the sql statement.    Here is the breakdown (superfluous code removed).  Using 3.0 code current as of 4/29/2014.  Is there something I am missing/    // Products which has many association of images:  class ProductsTable extends Table {        public function initialize(array $config) {          $this->table('products');          $this->displayField('name');          $this->primaryKey(['id']);          $this->addBehavior('Timestamp');            $this->hasMany('ProductImages', [                  'foreignKey' => 'product_id',                  //            'joinType' => 'LEFT'              ]);      }  }  // Product Images belongs to Products  class ProductImagesTable extends Table {      public function initialize(array $config)      {          $this->table('product_images');          $this->displayField('name');          $this->primaryKey(['id']);          $this->addBehavior('Timestamp');            $this->belongsTo(              'Products',              [                  'foreignKey' => 'product_id',                  //            'joinType' => 'LEFT'              ]          );      }  }    class ProductsController extends AppController {      public function index()      {          // calling $this->Products gives the same results          $p = TableRegistry::get('Products');          $pQuery = $p              ->find()              ->where(['status' => 'active'])              ->select(['id', 'name', 'price'])              ->order(['Product.name' => 'ASC'])              /* ====	 tried just calling  ->contain(['ProductImages')	=====  not working either */              ->contain(                  [                      'ProductImages' => function ($q) {                          return $q                              ->select(['id', 'product_id', 'name'])                              ->order(['ProductImages.position' => 'ASC']);                      }                  ]              );            pr($pQuery->sql());          // This shows the incorrect sql without the contain association          // SELECT Products.id AS `Products__id`, Products.name AS `Products__name`, Products.price AS `Products__price`          //    FROM products AS Products WHERE status = :c0 ORDER BY Product.name ASC            $pi = TableRegistry::get('ProductImages');          $piQuery = $pi              ->find('all')              ->select(['name', 'id', 'product_id'])              ->contain(['Products']);          pr($piQuery->sql());          // This shows the correct sql          // SELECT ProductImages.name AS `ProductImages__name`, ProductImages.id AS `ProductImages__id`,          // ProductImages.product_id AS `ProductImages__product_id`          // FROM product_images AS ProductImages          // LEFT JOIN products Products ON Products.id = (ProductImages.product_id)            exit;      }  }    

--
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+unsubscribe@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.