Re: CakePHP 3 - How to send X-CSRF-Token header

2014-08-31 Thread Dr. Tarique Sani
Thanks, would really appreciate some code to look at. Please do post if you
can when you get to a real computer.

Tarique




On Sat, Aug 30, 2014 at 6:11 PM, mark_story  wrote:

> I do this by adding a header with a jQuery beforeSend hook. I don't have
> an example handy as I am not at a real computer right now.
>
> -mark
>
> --
> 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.
>



-- 
=
Hire a CakePHP dev team : http://sanisoft.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+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: BelongsToMany model

2014-08-31 Thread José Lorenzo
You also have control over what is the foreignKey to use when creating the 
association. Refer the the ORM docs to customize what the query builder is 
doing.

On Sunday, August 31, 2014 7:30:36 PM UTC+2, Abdelmajid el Ibrahimi wrote:
>
> But even if i take that out it still says the same.
>
> Op zondag 31 augustus 2014 11:45:25 UTC+2 schreef José Lorenzo:
>>
>> There is no "public $primaryKey" in CakePHP 3.0
>>
>> You may use $this->primaryKey($myKey) inside the initialize() method
>>
>> On Sunday, August 31, 2014 3:54:56 AM UTC+2, Abdelmajid el Ibrahimi wrote:
>>>
>>> I have made two tables leerlingen and verzorgers. Because these have a 
>>> many to many relation i added a table leerlingen_verzorgers.
>>> I have added 3 model tables:
>>>
>>> class VerzorgersTable extends Table {
>>> public $primaryKey = 'verzorger_id';
>>> 
>>> public function initialize(array $config) {
>>> $this->belongsToMany('Leerlingen', 
>>> ['through' => 'LeerlingenVerzorgers',]);
>>> $this->addBehavior('Timestamp');
>>> }
>>> }
>>>
>>> class LeerlingenTable extends Table {
>>> public $primaryKey = 'leerling_id';
>>> 
>>> public function initialize(array $config) {
>>> $this->belongsToMany('Verzorgers', 
>>> ['through' => 'LeerlingenVerzorgers',]);
>>> $this->addBehavior('Timestamp');
>>> }
>>> }
>>>
>>> class LeerlingenVerzorgersTable extends Table {
>>> public function initialize(array $config) {
>>> $this->belongsTo('Leerlingen');
>>> $this->belongsTo('Verzorgers');
>>> }
>>> }
>>>
>>> Now when i want to retrieve a verzorger with all the leerlingen i get an 
>>> error that he doesn't know the leerlingen_id this is right because it is 
>>> leerling_id. But with the verzorgers table he does use the right id and 
>>> asks for the verzorger_id.
>>>
>>> My relation table looks like this:
>>> leerlingen_verzorgers
>>> --
>>> id
>>> leerling_id
>>> verzorgers_id
>>> jaar
>>>
>>> The generated query looks like this:
>>>
>>> 'SELECT Leerlingen.leerling_id AS `Leerlingen__leerling_id`, 
>>> Leerlingen.voornaam AS `Leerlingen__voornaam`, Leerlingen.achternaam AS 
>>> `Leerlingen__achternaam`, Leerlingen.geboortedatum AS 
>>> `Leerlingen__geboortedatum`, Leerlingen.geslacht AS `Leerlingen__geslacht`, 
>>> Leerlingen.email AS `Leerlingen__email`, Leerlingen.opmerking AS 
>>> `Leerlingen__opmerking`, LeerlingenVerzorgers.id AS 
>>> `LeerlingenVerzorgers__id`, LeerlingenVerzorgers.leerling_id AS 
>>> `LeerlingenVerzorgers__leerling_id`, LeerlingenVerzorgers.verzorger_id AS 
>>> `LeerlingenVerzorgers__verzorger_id`, LeerlingenVerzorgers.jaar AS 
>>> `LeerlingenVerzorgers__jaar` FROM leerlingen AS Leerlingen INNER JOIN 
>>> leerlingen_verzorgers LeerlingenVerzorgers ON 
>>> (LeerlingenVerzorgers.verzorger_id IN (:c0) AND Leerlingen.leerling_id = 
>>> (LeerlingenVerzorgers.leerlingen_id))
>>>
>>> so first he uses the right leerling_id but at the end he uses 
>>> leerlingen_id. Anyone knows what i did wrong?
>>>
>>>
>>>

-- 
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: 3.0 Possible to remove column?

2014-08-31 Thread José Lorenzo
You may also want to try the migrations plugin:

https://github.com/cakephp/migrations

On Sunday, August 31, 2014 8:24:21 PM UTC+2, Dieter Gribnitz wrote:
>
> Nevermind, I got it working.
> Pretty obvious.
> Just tried removeColumn(...) and it works.
> You might consider mentioning it in the documentation after the addColumn 
> section.
>

-- 
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: BelongsToMany model

2014-08-31 Thread Abdelmajid el Ibrahimi
But even if i take that out it still says the same.

Op zondag 31 augustus 2014 11:45:25 UTC+2 schreef José Lorenzo:
>
> There is no "public $primaryKey" in CakePHP 3.0
>
> You may use $this->primaryKey($myKey) inside the initialize() method
>
> On Sunday, August 31, 2014 3:54:56 AM UTC+2, Abdelmajid el Ibrahimi wrote:
>>
>> I have made two tables leerlingen and verzorgers. Because these have a 
>> many to many relation i added a table leerlingen_verzorgers.
>> I have added 3 model tables:
>>
>> class VerzorgersTable extends Table {
>> public $primaryKey = 'verzorger_id';
>> 
>> public function initialize(array $config) {
>> $this->belongsToMany('Leerlingen', 
>> ['through' => 'LeerlingenVerzorgers',]);
>> $this->addBehavior('Timestamp');
>> }
>> }
>>
>> class LeerlingenTable extends Table {
>> public $primaryKey = 'leerling_id';
>> 
>> public function initialize(array $config) {
>> $this->belongsToMany('Verzorgers', 
>> ['through' => 'LeerlingenVerzorgers',]);
>> $this->addBehavior('Timestamp');
>> }
>> }
>>
>> class LeerlingenVerzorgersTable extends Table {
>> public function initialize(array $config) {
>> $this->belongsTo('Leerlingen');
>> $this->belongsTo('Verzorgers');
>> }
>> }
>>
>> Now when i want to retrieve a verzorger with all the leerlingen i get an 
>> error that he doesn't know the leerlingen_id this is right because it is 
>> leerling_id. But with the verzorgers table he does use the right id and 
>> asks for the verzorger_id.
>>
>> My relation table looks like this:
>> leerlingen_verzorgers
>> --
>> id
>> leerling_id
>> verzorgers_id
>> jaar
>>
>> The generated query looks like this:
>>
>> 'SELECT Leerlingen.leerling_id AS `Leerlingen__leerling_id`, 
>> Leerlingen.voornaam AS `Leerlingen__voornaam`, Leerlingen.achternaam AS 
>> `Leerlingen__achternaam`, Leerlingen.geboortedatum AS 
>> `Leerlingen__geboortedatum`, Leerlingen.geslacht AS `Leerlingen__geslacht`, 
>> Leerlingen.email AS `Leerlingen__email`, Leerlingen.opmerking AS 
>> `Leerlingen__opmerking`, LeerlingenVerzorgers.id AS 
>> `LeerlingenVerzorgers__id`, LeerlingenVerzorgers.leerling_id AS 
>> `LeerlingenVerzorgers__leerling_id`, LeerlingenVerzorgers.verzorger_id AS 
>> `LeerlingenVerzorgers__verzorger_id`, LeerlingenVerzorgers.jaar AS 
>> `LeerlingenVerzorgers__jaar` FROM leerlingen AS Leerlingen INNER JOIN 
>> leerlingen_verzorgers LeerlingenVerzorgers ON 
>> (LeerlingenVerzorgers.verzorger_id IN (:c0) AND Leerlingen.leerling_id = 
>> (LeerlingenVerzorgers.leerlingen_id))
>>
>> so first he uses the right leerling_id but at the end he uses leerlingen_id. 
>> Anyone knows what i did wrong?
>>
>>
>>

-- 
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: 3.0 Possible to remove column?

2014-08-31 Thread Dieter Gribnitz
Nevermind, I got it working.
Pretty obvious.
Just tried removeColumn(...) and it works.
You might consider mentioning it in the documentation after the addColumn 
section.

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


3.0 Possible to remove column?

2014-08-31 Thread Dieter Gribnitz
I can't seem to find any method to remove columns via Database/Schema/Table.
Is there a way to do this?
I am creating an uninstaller for a plugin and this would come in handy.
If not I will just use a normal sql query instead.

-- 
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: 3.0 Plugin Installation DB schema setup

2014-08-31 Thread Dieter Gribnitz
Thanks,
That is exactly what I was looking for.

On Sunday, August 31, 2014 11:43:57 AM UTC+2, José Lorenzo wrote:
>
> For "packaging" and versioning the database I would suggest using the 
> migrations plugin:
>
> http://github.com/cakephp/migrations
>
> Composer has post install scripts you can setup. But it would be better to 
> let the user run the migrations on their own.
>
>
> On Sunday, August 31, 2014 10:46:49 AM UTC+2, Dieter Gribnitz wrote:
>>
>> Hi,
>> I had a look around on the web and could not find any documentation 
>> surrounding the setup of plugins.
>> If there are any documentation surrounding plugin packaging I would 
>> greatly appreciate someone pointing me in the right direction.
>> I have managed to set up a simple installer that loads the plugin via a 
>> git repo similar to debug-kit.
>>
>> Here are the basic questions I have regarding this:
>> Is there currently any way to export a part of your DB schema in 3.0 and 
>> package it in the config of the plugin on the git repo?
>> Is there any way to alter tables with version changes?
>> Are there any scripts that get triggered to run post plugin install or 
>> update?
>>
>> 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: 3.0.x - defaultConnectionName not working in Plugin

2014-08-31 Thread José Lorenzo
Hey, that's great news!

I was going  to bake a plugin application this evening to see if I could 
reproduce your problem. I'm glad you could figure it out!

On Sunday, August 31, 2014 5:42:21 PM UTC+2, Joe Theuerkauf wrote:
>
> Okay, i think i'm finally on the right track.
>
> As i noted, going to [host]/captchas was giving a Controller-not-found 
> error. i realize now it's because the route connecting '/captchas' required 
> an action to match... Oops. After trying the full URL that the Captcha 
> validator uses, i got a JSON response, but it was a 500 error, the database 
> was still trying to find the table *kodiak.captchas*. Changed 
> *TableRegistry::get('Captchas')* to 
> *TableRegistry::get('Thook/Websites.Captchas')* and got a JSON response i 
> expected.
>
> i know most of this is considered basic stuff, so i appreciate the 
> patience in trying to help me. At least i'm trying to figure it out on my 
> own while i wait for help, right? :)
> -joe
>
>
>
> On Saturday, 30 August 2014 12:28:50 UTC-4, Joe Theuerkauf wrote:
>>
>> @José: Here's what i'm using that works on the Contact page where i need 
>> to load the Captchas model to grab a question:
>>
>> Works:
>> Plugin::loadAll([
>> [
>> 'Thook/Websites' => ['routes' => true]
>> ]
>> ]);
>>
>> Also works:
>> Plugin::load('Thook/Websites');
>>
>> Doesn't work:
>> Plugin::load('Thook/Websites', ['routes' => true]);
>>
>> Results in ([...] shortening the path to relevant stuff):
>>
>> *Warning* (2): include([...]/Plugin/Thook\Websites\config\routes.php): 
>> failed to open stream: No such file or directory 
>> [*ROOT\vendor\cakephp\cakephp\src\Core\Plugin.php*, line *346*]
>>
>> *Warning* (2): include() [function.include]: Failed opening 
>> '[...]/Plugin/Thook\Websites\config\routes.php' for inclusion 
>> (include_path='.;C:\WebServer\php5\pear\pear') 
>> [*ROOT\vendor\cakephp\cakephp\src\Core\Plugin.php*, line *346*]
>>
>>
>> However, the file path it's trying to include IS valid (aside from 
>> directory separators).
>>
>> ---
>>
>> @mark
>> In my primary routes file:
>>
>> Router::scope('/', function(RouteBuilder $routes) {
>> // Some routes linking to main App Controllers, working.
>>
>> // Per your response:
>>
>>
>>
>>
>> *$routes->connect('/captchas/:action/*', ['plugin' => 
>> 'Thook/Websites','controller' => 'captchas' // Also tried 
>> 'Captchas', but the other routes' controller values are lower-case & 
>> working]);*
>> $routes->connect(':controller', ['action' => 'index], ['routeClass' 
>> => 'InflectedRoute']);
>>
>> $routes->connect('/:controller/:action/*', [], ['routeClass' => 
>> 'InflectedRoute']);
>>
>> // This will be dropped for production. ;)
>> $routes->connect('/', [
>> 'controller' => 'pages',
>> 'action' => 'display',
>> 'home'
>> ]);
>> });
>>
>> Still receiving Controller not found when i go directly to 
>> *[host]/captchas*:
>> Missing Controller
>>
>> *Error: * *CaptchasController* could not be found.
>>
>> *Error: * Create the class *CaptchasController* below in file: 
>> App\Controller\CaptchasController.php
>>
>> > namespace App\Controller;
>>
>> use App\Controller\AppController;
>>
>> class CaptchasController extends AppController {
>>
>> }
>>
>>
>> Thanks a lot guys, for taking a look at this with me.
>> -joe
>>
>>
>> On Saturday, 30 August 2014 08:33:57 UTC-4, mark_story wrote:
>>>
>>> If Router::plugin() isn't getting you the routes you want, you can 
>>> combine scope() and connect () to create the exact routes you want. Just 
>>> keep in mind that all the routing data that doesn't change should be in the 
>>> defaults list. For example
>>>
>>> $routes->connect('/captchas/:action/*', ['plugin' => 
>>> 'Thook/Websites','controller' => 'Captchas']);
>>>
>>> Would let you connect all the actions on the CaptchasController in your 
>>> plugin.
>>>
>>> -mark
>>>
>>>
>>

-- 
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: 3.0.x - defaultConnectionName not working in Plugin

2014-08-31 Thread Joe Theuerkauf
Okay, i think i'm finally on the right track.

As i noted, going to [host]/captchas was giving a Controller-not-found 
error. i realize now it's because the route connecting '/captchas' required 
an action to match... Oops. After trying the full URL that the Captcha 
validator uses, i got a JSON response, but it was a 500 error, the database 
was still trying to find the table *kodiak.captchas*. Changed 
*TableRegistry::get('Captchas')* to 
*TableRegistry::get('Thook/Websites.Captchas')* and got a JSON response i 
expected.

i know most of this is considered basic stuff, so i appreciate the patience 
in trying to help me. At least i'm trying to figure it out on my own while 
i wait for help, right? :)
-joe



On Saturday, 30 August 2014 12:28:50 UTC-4, Joe Theuerkauf wrote:
>
> @José: Here's what i'm using that works on the Contact page where i need 
> to load the Captchas model to grab a question:
>
> Works:
> Plugin::loadAll([
> [
> 'Thook/Websites' => ['routes' => true]
> ]
> ]);
>
> Also works:
> Plugin::load('Thook/Websites');
>
> Doesn't work:
> Plugin::load('Thook/Websites', ['routes' => true]);
>
> Results in ([...] shortening the path to relevant stuff):
>
> *Warning* (2): include([...]/Plugin/Thook\Websites\config\routes.php): failed 
> to open stream: No such file or directory 
> [*ROOT\vendor\cakephp\cakephp\src\Core\Plugin.php*, line *346*]
>
> *Warning* (2): include() [function.include]: Failed opening 
> '[...]/Plugin/Thook\Websites\config\routes.php' for inclusion 
> (include_path='.;C:\WebServer\php5\pear\pear') 
> [*ROOT\vendor\cakephp\cakephp\src\Core\Plugin.php*, line *346*]
>
>
> However, the file path it's trying to include IS valid (aside from 
> directory separators).
>
> ---
>
> @mark
> In my primary routes file:
>
> Router::scope('/', function(RouteBuilder $routes) {
> // Some routes linking to main App Controllers, working.
>
> // Per your response:
>
>
>
>
> *$routes->connect('/captchas/:action/*', ['plugin' => 
> 'Thook/Websites','controller' => 'captchas' // Also tried 
> 'Captchas', but the other routes' controller values are lower-case & 
> working]);*
> $routes->connect(':controller', ['action' => 'index], ['routeClass' => 
> 'InflectedRoute']);
>
> $routes->connect('/:controller/:action/*', [], ['routeClass' => 
> 'InflectedRoute']);
>
> // This will be dropped for production. ;)
> $routes->connect('/', [
> 'controller' => 'pages',
> 'action' => 'display',
> 'home'
> ]);
> });
>
> Still receiving Controller not found when i go directly to 
> *[host]/captchas*:
> Missing Controller
>
> *Error: * *CaptchasController* could not be found.
>
> *Error: * Create the class *CaptchasController* below in file: 
> App\Controller\CaptchasController.php
>
>  namespace App\Controller;
>
> use App\Controller\AppController;
>
> class CaptchasController extends AppController {
>
> }
>
>
> Thanks a lot guys, for taking a look at this with me.
> -joe
>
>
> On Saturday, 30 August 2014 08:33:57 UTC-4, mark_story wrote:
>>
>> If Router::plugin() isn't getting you the routes you want, you can 
>> combine scope() and connect () to create the exact routes you want. Just 
>> keep in mind that all the routing data that doesn't change should be in the 
>> defaults list. For example
>>
>> $routes->connect('/captchas/:action/*', ['plugin' => 
>> 'Thook/Websites','controller' => 'Captchas']);
>>
>> Would let you connect all the actions on the CaptchasController in your 
>> plugin.
>>
>> -mark
>>
>>
>

-- 
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: find all on complex model

2014-08-31 Thread ajt
Hi Stephen,
Yes your example was a great effort and I solved the problem. The issue is 
that I didnt add the fields argument in so this kept giving me undefined 
errors.
I dont think your code will work as you dont specify fields.
Your models are setup like mine s that was really well done.

Also I need a find all as find first returns only 1 row.



  $this->Lesson->recursive = -1;
 
$options['joins'] = array(
   array('table' => 'lessons_students',
'alias' => 'LessonsStudent',
'type' => 'LEFT',
'conditions' => array(
'Lesson.id = LessonsStudent.lesson_id',
 )
 ),

array('table' => 'students',
'alias' => 'Student',
'type' => 'LEFT',
'conditions' => array(
'LessonsStudent.student_id=Student.id',
 )
 ),

);


 

 
  $options['fields'] = array('Student.*','Lesson.*','LessonsStudent.*');

 $options['conditions'] = array('Lesson.tutor_id'  => 2);


   $student=$this->set( 'student',$this->Lesson->find('all', $options));

-- 
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: find all on complex model

2014-08-31 Thread Thomas von Hassel
There are plenty of complete examples here:

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




On 31 Aug 2014, at 10:06, ajt  wrote:

> I tried this and as expected it doesnt work and it cant work because HABTM is 
> a different case.
> THis has to be the hardest framework to just get data to display from tables. 
> There just is no docs for a complete example.
> 
>   $student=  $this->Lesson->find('all', array('contain' => array( 'Student' , 
> 'Tutor')));
> 
> -- 
> 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: BelongsToMany model

2014-08-31 Thread José Lorenzo
There is no "public $primaryKey" in CakePHP 3.0

You may use $this->primaryKey($myKey) inside the initialize() method

On Sunday, August 31, 2014 3:54:56 AM UTC+2, Abdelmajid el Ibrahimi wrote:
>
> I have made two tables leerlingen and verzorgers. Because these have a 
> many to many relation i added a table leerlingen_verzorgers.
> I have added 3 model tables:
>
> class VerzorgersTable extends Table {
> public $primaryKey = 'verzorger_id';
> 
> public function initialize(array $config) {
> $this->belongsToMany('Leerlingen', 
> ['through' => 'LeerlingenVerzorgers',]);
> $this->addBehavior('Timestamp');
> }
> }
>
> class LeerlingenTable extends Table {
> public $primaryKey = 'leerling_id';
> 
> public function initialize(array $config) {
> $this->belongsToMany('Verzorgers', 
> ['through' => 'LeerlingenVerzorgers',]);
> $this->addBehavior('Timestamp');
> }
> }
>
> class LeerlingenVerzorgersTable extends Table {
> public function initialize(array $config) {
> $this->belongsTo('Leerlingen');
> $this->belongsTo('Verzorgers');
> }
> }
>
> Now when i want to retrieve a verzorger with all the leerlingen i get an 
> error that he doesn't know the leerlingen_id this is right because it is 
> leerling_id. But with the verzorgers table he does use the right id and 
> asks for the verzorger_id.
>
> My relation table looks like this:
> leerlingen_verzorgers
> --
> id
> leerling_id
> verzorgers_id
> jaar
>
> The generated query looks like this:
>
> 'SELECT Leerlingen.leerling_id AS `Leerlingen__leerling_id`, 
> Leerlingen.voornaam AS `Leerlingen__voornaam`, Leerlingen.achternaam AS 
> `Leerlingen__achternaam`, Leerlingen.geboortedatum AS 
> `Leerlingen__geboortedatum`, Leerlingen.geslacht AS `Leerlingen__geslacht`, 
> Leerlingen.email AS `Leerlingen__email`, Leerlingen.opmerking AS 
> `Leerlingen__opmerking`, LeerlingenVerzorgers.id AS 
> `LeerlingenVerzorgers__id`, LeerlingenVerzorgers.leerling_id AS 
> `LeerlingenVerzorgers__leerling_id`, LeerlingenVerzorgers.verzorger_id AS 
> `LeerlingenVerzorgers__verzorger_id`, LeerlingenVerzorgers.jaar AS 
> `LeerlingenVerzorgers__jaar` FROM leerlingen AS Leerlingen INNER JOIN 
> leerlingen_verzorgers LeerlingenVerzorgers ON 
> (LeerlingenVerzorgers.verzorger_id IN (:c0) AND Leerlingen.leerling_id = 
> (LeerlingenVerzorgers.leerlingen_id))
>
> so first he uses the right leerling_id but at the end he uses leerlingen_id. 
> Anyone knows what i did wrong?
>
>
>

-- 
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: 3.0 Plugin Installation DB schema setup

2014-08-31 Thread José Lorenzo
For "packaging" and versioning the database I would suggest using the 
migrations plugin:

http://github.com/cakephp/migrations

Composer has post install scripts you can setup. But it would be better to 
let the user run the migrations on their own.


On Sunday, August 31, 2014 10:46:49 AM UTC+2, Dieter Gribnitz wrote:
>
> Hi,
> I had a look around on the web and could not find any documentation 
> surrounding the setup of plugins.
> If there are any documentation surrounding plugin packaging I would 
> greatly appreciate someone pointing me in the right direction.
> I have managed to set up a simple installer that loads the plugin via a 
> git repo similar to debug-kit.
>
> Here are the basic questions I have regarding this:
> Is there currently any way to export a part of your DB schema in 3.0 and 
> package it in the config of the plugin on the git repo?
> Is there any way to alter tables with version changes?
> Are there any scripts that get triggered to run post plugin install or 
> update?
>
> 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.


BelongsToMany model

2014-08-31 Thread Abdelmajid el Ibrahimi
I have made two tables leerlingen and verzorgers. Because these have a many 
to many relation i added a table leerlingen_verzorgers.
I have added 3 model tables:

class VerzorgersTable extends Table {
public $primaryKey = 'verzorger_id';

public function initialize(array $config) {
$this->belongsToMany('Leerlingen', 
['through' => 'LeerlingenVerzorgers',]);
$this->addBehavior('Timestamp');
}
}

class LeerlingenTable extends Table {
public $primaryKey = 'leerling_id';

public function initialize(array $config) {
$this->belongsToMany('Verzorgers', 
['through' => 'LeerlingenVerzorgers',]);
$this->addBehavior('Timestamp');
}
}

class LeerlingenVerzorgersTable extends Table {
public function initialize(array $config) {
$this->belongsTo('Leerlingen');
$this->belongsTo('Verzorgers');
}
}

Now when i want to retrieve a verzorger with all the leerlingen i get an 
error that he doesn't know the leerlingen_id this is right because it is 
leerling_id. But with the verzorgers table he does use the right id and 
asks for the verzorger_id.

My relation table looks like this:
leerlingen_verzorgers
--
id
leerling_id
verzorgers_id
jaar

The generated query looks like this:

'SELECT Leerlingen.leerling_id AS `Leerlingen__leerling_id`, 
Leerlingen.voornaam AS `Leerlingen__voornaam`, Leerlingen.achternaam AS 
`Leerlingen__achternaam`, Leerlingen.geboortedatum AS 
`Leerlingen__geboortedatum`, Leerlingen.geslacht AS `Leerlingen__geslacht`, 
Leerlingen.email AS `Leerlingen__email`, Leerlingen.opmerking AS 
`Leerlingen__opmerking`, LeerlingenVerzorgers.id AS `LeerlingenVerzorgers__id`, 
LeerlingenVerzorgers.leerling_id AS `LeerlingenVerzorgers__leerling_id`, 
LeerlingenVerzorgers.verzorger_id AS `LeerlingenVerzorgers__verzorger_id`, 
LeerlingenVerzorgers.jaar AS `LeerlingenVerzorgers__jaar` FROM leerlingen AS 
Leerlingen INNER JOIN leerlingen_verzorgers LeerlingenVerzorgers ON 
(LeerlingenVerzorgers.verzorger_id IN (:c0) AND Leerlingen.leerling_id = 
(LeerlingenVerzorgers.leerlingen_id))

so first he uses the right leerling_id but at the end he uses leerlingen_id. 
Anyone knows what i did wrong?


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


3.0 Plugin Installation DB schema setup

2014-08-31 Thread Dieter Gribnitz
Hi,
I had a look around on the web and could not find any documentation 
surrounding the setup of plugins.
If there are any documentation surrounding plugin packaging I would greatly 
appreciate someone pointing me in the right direction.
I have managed to set up a simple installer that loads the plugin via a git 
repo similar to debug-kit.

Here are the basic questions I have regarding this:
Is there currently any way to export a part of your DB schema in 3.0 and 
package it in the config of the plugin on the git repo?
Is there any way to alter tables with version changes?
Are there any scripts that get triggered to run post plugin install or 
update?

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: find all on complex model

2014-08-31 Thread Stephen S
Again if this isn't working it's likely your tables or associations are
wrong, can you provide a pastie.


On 31 August 2014 09:06, ajt  wrote:

> I tried this and as expected it doesnt work and it cant work because HABTM
> is a different case.
> THis has to be the hardest framework to just get data to display from
> tables. There just is no docs for a complete example.
>
>   $student=  $this->Lesson->find('all', array('contain' => array(
> 'Student' , 'Tutor')));
>
> --
> 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.
>



-- 
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+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: find all on complex model

2014-08-31 Thread ajt
I tried this and as expected it doesnt work and it cant work because HABTM 
is a different case.
THis has to be the hardest framework to just get data to display from 
tables. There just is no docs for a complete example.

  $student=  $this->Lesson->find('all', array('contain' => array( 'Student' 
, 'Tutor')));

-- 
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: find all on complex model

2014-08-31 Thread Stephen S
You haven't provided any code other than a straight forward find query,
we're likely to point you to book when this is the case, we need your code
to help you also (like when I asked to see your associations).

Here's an example based on the models and desired relationships you
mentioned, this works for me but it assumes you've named your tables
correctly like such:

*lessons*
> id | tutor_id | ...
> *lesson_students*
> id | lesson_id | student_id
> *tutors*
> id | ...
> *students*
> id | ...


The link is: http://pastie.org/private/vlod0ibqmwdf4geszb9fa

It's much more simple to use contain over joins and hopefully you can see
why.

Also notice the 'with' part on the HABTM joins, writing this tells the
association which model to use to join the tables, you can leave this blank
and it will create a model on the fly. See more in the HABTM docs on this.

Specifying one in advance this way allows you to access the join model
easily and write methods within it, it's not required.


On 31 August 2014 01:05, ajt  wrote:

> No this is not what you do as the Student has a HABTM relationship and I
> am told to do joins.
>
> Also when saying adding something I NEED the code as please dont  assume
> by adding containable I know what your talking about or the docs explain
> things.
>
> I dont understand why simply getting information from 4 tables is just so
> complicated and where is the complete examples of this?
>
>
>
>
>
>  --
> 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.
>



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