Re: CakePHP 3.0 - Confusion comes from

2015-03-30 Thread Md Bayezid Alam
Good point.. [?]

On Tue, Mar 31, 2015 at 2:28 AM, Dave Edwards 
wrote:

> Thanks for the reply.
>
> In that case not only is the blog tutorial wrong, but the manual is
> misleading as well.
>
> In http://book.cakephp.org/3.0/en/orm/saving-data.html patchEntity is not
> introduced until the section 'Merging Request Data Into Entities' at which
> point it has moved on from explaining how to save data to updating it.
>
> Dave
>
>
> On Monday, 30 March 2015 09:16:50 UTC+1, euromark wrote:
>>
>> no, patchEntity is what it is: it patches data into the entity
>> that is necessary for ALL forms, so both add and edit ones of course.
>>
>>
>> Am Sonntag, 29. März 2015 21:15:28 UTC+2 schrieb Dave Edwards:
>>>
>>> Why has the first method (which is the correct one) got both
>>>
>>> $this->Articles->newEntity()
>>>
>>> and
>>>
>>>  $this->Articles->patchEntity()
>>>
>>> when you are saving a new record?
>>>
>>> I thought that newEntity was used when inserting new data, and
>>> patchEntity was for updating existing data? Is my understanding incorrect?
>>>
>>> Dave
>>>
>>> On Friday, 27 March 2015 21:24:38 UTC, euromark wrote:
>>>
>>> The latter is deprecated, this changed during RC and as such the
>>> tutorial needs some updating.
>>> Thats all there is to it :)
>>>
>>> Mark
>>>
>>>
>>> Am Freitag, 27. März 2015 15:37:26 UTC+1 schrieb Bayezid Alam:
>>>
>>> Hi,
>>>
>>> A confusion comes on my mind regarding the adding something on CakePHP
>>> 3.0
>>>
>>> As example given on below link's in the add function.
>>> http://book.cakephp.org/3.0/en/tutorials-and-examples/
>>> blog/part-two.html#adding-articles
>>>
>>> public function add()
>>> {
>>> $article = $this->Articles->newEntity(); // *A blank newEnttity 
>>> added stored in $article variable*
>>> if ($this->request->is('post')) {
>>> $article = $this->Articles->patchEntity($article, 
>>> $this->request->data); // *A patchEntity added here & passed the request 
>>> data here*
>>> if ($this->Articles->save($article)) {
>>> $this->Flash->success(__('Your article has been saved.'));
>>> return $this->redirect(['action' => 'index']);
>>> }
>>> $this->Flash->error(__('Unable to add your article.'));
>>> }
>>> $this->set('article', $article);
>>> }
>>>
>>>
>>>
>>> But i found a different things on below link
>>> http://book.cakephp.org/3.0/en/tutorials-and-examples/
>>> blog-auth-example/auth.html#creating-all-user-related-code
>>>
>>> public function add()
>>> {
>>> $user = $this->Users->newEntity($this->request->data); // *request 
>>> data passing through newEntity here*
>>> if ($this->request->is('post')) {
>>> if ($this->Users->save($user)) {
>>> $this->Flash->success(__('The user has been saved.'
>>>
>>> ...
>>
>>  --
> 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: CakePHP 2 v CakePHP 3 SQL

2015-03-30 Thread Dave Edwards
BUMP!

On Tuesday, 24 March 2015 20:33:49 UTC, Dave Edwards wrote:
>
> Thanks for the reply,
>
> That being the case, I am pleasantly surprised that despite the 
> documentation making a big play on how different the new ORM is, I can (if 
> I choose) create my queries in much the same way.
>
> The example I posted was a effectively a find 'all' (paginated using a 
> limit clause). What about a find first, is this still as straightforward? 
> Here is an example from the same controller, how would that translate 
> please?
>
>
> $options = array(
> 'conditions' => array(
> 'Rental.id' => $id,
> ),
> 'contain' => array(
> 'Trailer' => array(
> 'fields' => array('id', 'number', 'make', 
> 'year', 'license', 'vin', 'skirt')
> ),
> 'Lessee' => array(
> 'fields' => array('id', 'account', 'name', 
> 'address_1', 'address_2', 'city', 'state', 'zip_1', 'zip_2')
> )
> )
> );
>
>
> $this->request->data = $this->Rental->find('first', $options);
>
> Dave
>
> On Tuesday, 24 March 2015 13:04:21 UTC, Dave Edwards wrote:
>>
>> Here is a sample of some code I use in a Trailer rental application. This 
>> is a method from the Rental Controller.
>>
>> Rental hasMany Trailers and hasMany Lessees
>>
>> public function archived($id = null) {
>>
>>
>> $options = array(
>>   'limit' => 10,
>>   'order' => 'Trailer.number ASC',
>>   'fields' => array('id', 'trailer_id', 'lessee_id', 'date_out', 
>> 'rented', 'agreement_number'),
>>   'conditions' => array(
>>   'Rental.deleted' => '1',
>>   ),
>>   'contain' => array(
>>   'Trailer' => array(
>>   'fields' => array('id', 'number', 'make', 'license'),
>>   ),
>>   'Lessee' => array(
>>   'fields' => array('id', 'account', 'name'),
>>   )
>>   )
>> );
>>
>>
>> $this->paginate = $options;
>> $this->set('rentals', $this->paginate());
>>  }
>>
>>
>> Turning off recursive, and using Containable provides a very flexible and 
>> readable method of building a query. Adding conditions, fields, associated 
>> models etc is a snip. Whoever produced this method of working should be 
>> fully credited.
>>
>> My question is, how would something like this be created in CakePHP 3? 
>> There seem to be many many more pages to read and understand regarding the 
>> new ORM, and I'm really unsure how simple it will be to convert. Will I be 
>> able to achieve it in the a similar manner, and will it be as readable, and 
>> easy to edit?
>>
>> Are there any examples in the new Manual (I can't find any), where the 
>> new ORM is used to bring all the new methods of working together in much 
>> the same way as the method above?
>>
>> Thanks
>>
>> Dave
>>
>

-- 
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: CakePHP 3.0 - Confusion comes from

2015-03-30 Thread Dave Edwards
Thanks for the reply.

In that case not only is the blog tutorial wrong, but the manual is 
misleading as well.

In http://book.cakephp.org/3.0/en/orm/saving-data.html patchEntity is not 
introduced until the section 'Merging Request Data Into Entities' at which 
point it has moved on from explaining how to save data to updating it.

Dave


On Monday, 30 March 2015 09:16:50 UTC+1, euromark wrote:
>
> no, patchEntity is what it is: it patches data into the entity
> that is necessary for ALL forms, so both add and edit ones of course.
>
>
> Am Sonntag, 29. März 2015 21:15:28 UTC+2 schrieb Dave Edwards:
>>
>> Why has the first method (which is the correct one) got both 
>>
>> $this->Articles->newEntity()
>>
>> and
>>
>>  $this->Articles->patchEntity()
>>
>> when you are saving a new record?
>>
>> I thought that newEntity was used when inserting new data, and 
>> patchEntity was for updating existing data? Is my understanding incorrect?
>>
>> Dave
>>
>> On Friday, 27 March 2015 21:24:38 UTC, euromark wrote:
>>
>> The latter is deprecated, this changed during RC and as such the tutorial 
>> needs some updating.
>> Thats all there is to it :)
>>
>> Mark
>>
>>
>> Am Freitag, 27. März 2015 15:37:26 UTC+1 schrieb Bayezid Alam:
>>
>> Hi,
>>
>> A confusion comes on my mind regarding the adding something on CakePHP 3.0
>>
>> As example given on below link's in the add function.
>>
>> http://book.cakephp.org/3.0/en/tutorials-and-examples/blog/part-two.html#adding-articles
>>
>> public function add()
>> {
>> $article = $this->Articles->newEntity(); // *A blank newEnttity 
>> added stored in $article variable*
>> if ($this->request->is('post')) {
>> $article = $this->Articles->patchEntity($article, 
>> $this->request->data); // *A patchEntity added here & passed the request 
>> data here*
>> if ($this->Articles->save($article)) {
>> $this->Flash->success(__('Your article has been saved.'));
>> return $this->redirect(['action' => 'index']);
>> }
>> $this->Flash->error(__('Unable to add your article.'));
>> }
>> $this->set('article', $article);
>> }
>>
>>
>>
>> But i found a different things on below link
>>
>> http://book.cakephp.org/3.0/en/tutorials-and-examples/blog-auth-example/auth.html#creating-all-user-related-code
>>
>> public function add()
>> {
>> $user = $this->Users->newEntity($this->request->data); // *request 
>> data passing through newEntity here*
>> if ($this->request->is('post')) {
>> if ($this->Users->save($user)) {
>> $this->Flash->success(__('The user has been saved.'
>>
>> ...
>
>

-- 
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: Error linking forum titles to individual posts.

2015-03-30 Thread Odedere Ayokunle
Thanks. It works perfectly now. You guys are quite nice here, unlike the 
people on Stackoverflow that are fond of banning me for some days just 
because I incorrectly asked a question.  

On Sunday, 29 March 2015 20:49:57 UTC+1, Odedere Ayokunle wrote:
>
> Greetings everyone here. I am combining one Andrew Perkin video tutorial 
> (which explains cakephp in a step by step manner but quite stale) with the 
> official cake forum example (more current but less explanatory) in learning 
> cakePHP. The first thing I learnt how to do was to view all posts on the 
> index page, which works very fine. Then I proceeded to using "id's" to view 
> individual posts through the "view" action, this also works perfectly. My 
> challenge started when I wanted to link titles on the index page to their 
> individual forum posts. I do not seem to get the link class well. I tried 
> Andrew Perkin's approach but I was showed errors. Then I updated his 
> version to the official cake example style (adding helpers, exception for 
> null id's, etc), but still I am being told that "Fatal Error
>
> *Error: *Cannot access empty property 
> *File: *C:\xampp\htdocs\cakephp\lib\Cake\View\View.php 
> *Line: *867" 
>
> The surprising thing about this error is that I have never edited the 
> contents on the ../lib directory. So I do not know how to rectify it. I am 
> only used to the ../app directory. 
>
> Kindly find my code below and the associated file paths:
>
>  MODEL 
> cakephp/app/Model/Writeup.php
>
>  class Writeup extends AppModel {
> var $name='Writeup';
> }
> ?>
>
> CONTROLLER
> cakephp/app/Controller/WriteupsController.php
>
> class WriteupsController extends AppController {
> public $helpers = array('Html','Form');
>
> public function index() {
> $this->set('writeups',$this->Writeup->find('all'));
> }
>
> public function view($id = null) {
> $this->set('writeup',$this->Writeup->findById($id));
> }
>
> public function hello_world() {
> }
> }
> ?>
>
> VIEW
> cakephp/app/Views/Writeups/index.ctp
>  View All Posts
>
> 
>
> Title
> Body
>
> 
>
>  $Html->link($writeup['Writeup']['title'],
>  array('controller'=>'writeups', 
> 'action'=>'view',$writeup['Writeup']['id']));?> 
>   
>
>
>  
> 
>
> ##
> cakephp/app/Views/Writeups/view.ctp
>
>  
> 
>
> Created on: 
>  Last modified on:  ?>
> ###
> Once again, the error being provided by the debugger is that "Cannot 
> access empty property" and the file path of the error is "
> C:\xampp\htdocs\cakephp\lib\Cake\View\View.php", a path that I have never 
> edited. 
>
> Thank you.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

-- 
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: CakePHP 3.0 - Confusion comes from

2015-03-30 Thread euromark
no, patchEntity is what it is: it patches data into the entity
that is necessary for ALL forms, so both add and edit ones of course.


Am Sonntag, 29. März 2015 21:15:28 UTC+2 schrieb Dave Edwards:
>
> Why has the first method (which is the correct one) got both 
>
> $this->Articles->newEntity()
>
> and
>
>  $this->Articles->patchEntity()
>
> when you are saving a new record?
>
> I thought that newEntity was used when inserting new data, and patchEntity 
> was for updating existing data? Is my understanding incorrect?
>
> Dave
>
> On Friday, 27 March 2015 21:24:38 UTC, euromark wrote:
>
> The latter is deprecated, this changed during RC and as such the tutorial 
> needs some updating.
> Thats all there is to it :)
>
> Mark
>
>
> Am Freitag, 27. März 2015 15:37:26 UTC+1 schrieb Bayezid Alam:
>
> Hi,
>
> A confusion comes on my mind regarding the adding something on CakePHP 3.0
>
> As example given on below link's in the add function.
>
> http://book.cakephp.org/3.0/en/tutorials-and-examples/blog/part-two.html#adding-articles
>
> public function add()
> {
> $article = $this->Articles->newEntity(); // *A blank newEnttity added 
> stored in $article variable*
> if ($this->request->is('post')) {
> $article = $this->Articles->patchEntity($article, 
> $this->request->data); // *A patchEntity added here & passed the request data 
> here*
> if ($this->Articles->save($article)) {
> $this->Flash->success(__('Your article has been saved.'));
> return $this->redirect(['action' => 'index']);
> }
> $this->Flash->error(__('Unable to add your article.'));
> }
> $this->set('article', $article);
> }
>
>
>
> But i found a different things on below link
>
> http://book.cakephp.org/3.0/en/tutorials-and-examples/blog-auth-example/auth.html#creating-all-user-related-code
>
> public function add()
> {
> $user = $this->Users->newEntity($this->request->data); // *request 
> data passing through newEntity here*
> if ($this->request->is('post')) {
> if ($this->Users->save($user)) {
> $this->Flash->success(__('The user has been saved.'
>
> ...

-- 
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: Error linking forum titles to individual posts.

2015-03-30 Thread José Lorenzo
The problem is doing  $this->$Html->

It should be  $this->Html->

On Sunday, March 29, 2015 at 9:49:57 PM UTC+2, Odedere Ayokunle wrote:
>
> Greetings everyone here. I am combining one Andrew Perkin video tutorial 
> (which explains cakephp in a step by step manner but quite stale) with the 
> official cake forum example (more current but less explanatory) in learning 
> cakePHP. The first thing I learnt how to do was to view all posts on the 
> index page, which works very fine. Then I proceeded to using "id's" to view 
> individual posts through the "view" action, this also works perfectly. My 
> challenge started when I wanted to link titles on the index page to their 
> individual forum posts. I do not seem to get the link class well. I tried 
> Andrew Perkin's approach but I was showed errors. Then I updated his 
> version to the official cake example style (adding helpers, exception for 
> null id's, etc), but still I am being told that "Fatal Error
>
> *Error: *Cannot access empty property 
> *File: *C:\xampp\htdocs\cakephp\lib\Cake\View\View.php 
> *Line: *867" 
>
> The surprising thing about this error is that I have never edited the 
> contents on the ../lib directory. So I do not know how to rectify it. I am 
> only used to the ../app directory. 
>
> Kindly find my code below and the associated file paths:
>
>  MODEL 
> cakephp/app/Model/Writeup.php
>
>  class Writeup extends AppModel {
> var $name='Writeup';
> }
> ?>
>
> CONTROLLER
> cakephp/app/Controller/WriteupsController.php
>
> class WriteupsController extends AppController {
> public $helpers = array('Html','Form');
>
> public function index() {
> $this->set('writeups',$this->Writeup->find('all'));
> }
>
> public function view($id = null) {
> $this->set('writeup',$this->Writeup->findById($id));
> }
>
> public function hello_world() {
> }
> }
> ?>
>
> VIEW
> cakephp/app/Views/Writeups/index.ctp
>  View All Posts
>
> 
>
> Title
> Body
>
> 
>
>  $Html->link($writeup['Writeup']['title'],
>  array('controller'=>'writeups', 
> 'action'=>'view',$writeup['Writeup']['id']));?> 
>   
>
>
>  
> 
>
> ##
> cakephp/app/Views/Writeups/view.ctp
>
>  
> 
>
> Created on: 
>  Last modified on:  ?>
> ###
> Once again, the error being provided by the debugger is that "Cannot 
> access empty property" and the file path of the error is "
> C:\xampp\htdocs\cakephp\lib\Cake\View\View.php", a path that I have never 
> edited. 
>
> Thank you.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

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