Auth component with Logins model

2016-02-29 Thread Abdelmajid el Ibrahimi
Hello,

I have made a Logins table separate from the Users table. I have changed 
'authenticate' => [
'Basic' => [
'userModel' => 'Logins'
],
]

It works the only problem i have is that the session doesnt get destroyed. 
I have destroyed it and it shows nothing but something keeps writing the 
data back to the session. Does somebody know what it is.

   unset($_SESSION);
return $this->redirect($this->Auth->logout());

I do this and i see that the superglobals Session variable is getting 
changed and the Auth.User is getting removed but at the end of the script 
something writes it back.

-- 
Sign up for our Newsletter for updates.
http://cakephp.org/newsletter/signup

We will soon be closing this Google Group. But don't worry, we have something 
better coming. Stay tuned for an updated from the CakePHP Team soon.

Like Us on FaceBook https://www.facebook.com/CakePHP
Follow 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.
For more options, visit https://groups.google.com/d/optout.


Re: baking a model of users

2015-09-06 Thread Abdelmajid el Ibrahimi
i did the problem now is it says column name user_id not found.

see the question:

http://stackoverflow.com/questions/32429448/cakephp-column-not-found-1054-user-id/32429902#32429902

Met vriendelijke groet,
A. el Ibrahimi
According to cake convention the primary key of any table should be namd id.
Foreign keys consist of a singular table name with _id appended.
Rename your primary key to id and bake again and it should work as expected.

--
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 a topic in the
Google Groups "CakePHP" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/cake-php/9WfjeCEzyis/unsubscribe.
To unsubscribe from this group and all its topics, 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: baking a model of users

2015-09-06 Thread Abdelmajid el Ibrahimi
I see what happend but i just don't get why. There is a belongs to made for 
the same table. When is remove that everything works fine. Anybody knows 
why?

Op zondag 6 september 2015 15:55:33 UTC+2 schreef Abdelmajid el Ibrahimi:
>
> Hello,
>
> I have made a table named users with a id and a username and a password
> The problem is when i bake the model i get the next model:
>
>   $this->table('users');
> $this->displayField('user_id');
> $this->primaryKey('user_id');
>
> $this->belongsTo('Users', [
> 'foreignKey' => 'user_id',
> 'joinType' => 'INNER'
> ]);
> $this->belongsToMany('Educations', [
> 'foreignKey' => 'user_id',
> 'targetForeignKey' => 'education_id',
> 'joinTable' => 'users_educations'
> ]);
> $this->belongsToMany('Roles', [
> 'foreignKey' => 'user_id',
> 'targetForeignKey' => 'role_id',
> 'joinTable' => 'users_roles'
> ]);
> $this->belongsToMany('Subjects', [
> 'foreignKey' => 'user_id',
> 'targetForeignKey' => 'subject_id',
> 'joinTable' => 'users_subjects'
> ]);
> }
>
> /**
>  * Default validation rules.
>  *
>  * @param \Cake\Validation\Validator $validator Validator instance.
>  * @return \Cake\Validation\Validator
>  */
> public function validationDefault(Validator $validator)
> {
> $validator
> ->requirePresence('username', 'create')
> ->notEmpty('username');
>
> $validator
> ->requirePresence('password', 'create')
> ->notEmpty('password');
>
> return $validator;
> }
>
> /**
>  * Returns a rules checker object that will be used for validating
>  * application integrity.
>  *
>  * @param \Cake\ORM\RulesChecker $rules The rules object to be 
> modified.
>  * @return \Cake\ORM\RulesChecker
>  */
> public function buildRules(RulesChecker $rules)
> {
> $rules->add($rules->isUnique(['username']));
> $rules->add($rules->existsIn(['user_id'], 'Users'));
> return $rules;
> }
>
> What i dont get is why the table users belongs to users because that is 
> what my controller says. now i get a fault saying that:
>
> SELECT Users.user_id AS `Users__user_id`, Users.username AS 
> `Users__username`, Users.password AS `Users__password` FROM users Users INNER 
> JOIN users Users ON Users.user_id = (Users.user_id) LIMIT 20 OFFSET 0
>
> gives error: *Error: *
> SQLSTATE[42000]: Syntax error or access violation: 1066 Table/alias: 
> 'Users' non unique
>
>
>

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


baking a model of users

2015-09-06 Thread Abdelmajid el Ibrahimi
Hello,

I have made a table named users with a id and a username and a password
The problem is when i bake the model i get the next model:

  $this->table('users');
$this->displayField('user_id');
$this->primaryKey('user_id');

$this->belongsTo('Users', [
'foreignKey' => 'user_id',
'joinType' => 'INNER'
]);
$this->belongsToMany('Educations', [
'foreignKey' => 'user_id',
'targetForeignKey' => 'education_id',
'joinTable' => 'users_educations'
]);
$this->belongsToMany('Roles', [
'foreignKey' => 'user_id',
'targetForeignKey' => 'role_id',
'joinTable' => 'users_roles'
]);
$this->belongsToMany('Subjects', [
'foreignKey' => 'user_id',
'targetForeignKey' => 'subject_id',
'joinTable' => 'users_subjects'
]);
}

/**
 * Default validation rules.
 *
 * @param \Cake\Validation\Validator $validator Validator instance.
 * @return \Cake\Validation\Validator
 */
public function validationDefault(Validator $validator)
{
$validator
->requirePresence('username', 'create')
->notEmpty('username');

$validator
->requirePresence('password', 'create')
->notEmpty('password');

return $validator;
}

/**
 * Returns a rules checker object that will be used for validating
 * application integrity.
 *
 * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
 * @return \Cake\ORM\RulesChecker
 */
public function buildRules(RulesChecker $rules)
{
$rules->add($rules->isUnique(['username']));
$rules->add($rules->existsIn(['user_id'], 'Users'));
return $rules;
}

What i dont get is why the table users belongs to users because that is 
what my controller says. now i get a fault saying that:

SELECT Users.user_id AS `Users__user_id`, Users.username AS `Users__username`, 
Users.password AS `Users__password` FROM users Users INNER JOIN users Users ON 
Users.user_id = (Users.user_id) LIMIT 20 OFFSET 0

gives error: *Error: *
SQLSTATE[42000]: Syntax error or access violation: 1066 Table/alias: 
'Users' non unique


-- 
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: setisodate function

2014-10-14 Thread Abdelmajid el Ibrahimi
Already solved it.

Op woensdag 15 oktober 2014 01:34:08 UTC+2 schreef Abdelmajid el Ibrahimi:
>
> Hello,
>
> setisodate is a datetime function that can give you a date by entering 
> year, week, day. Only the problem is i cant get it to work:
> $time=new Time($datum);
> $week= $time->format('%W');
> $jaar= $time->format('%Y');
> $datum= $time->setISODate($jaar,$week,$weekdag); //year , week num , day
> return $datum;
>
> It gives me a error back i read that Time class includes DATETIME
>

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


setisodate function

2014-10-14 Thread Abdelmajid el Ibrahimi
Hello,

setisodate is a datetime function that can give you a date by entering 
year, week, day. Only the problem is i cant get it to work:
$time=new Time($datum);
$week= $time->format('%W');
$jaar= $time->format('%Y');
$datum= $time->setISODate($jaar,$week,$weekdag); //year , week num , day
return $datum;

It gives me a error back i read that Time class includes DATETIME

-- 
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.0-beta2 released

2014-10-14 Thread Abdelmajid el Ibrahimi
Hello,

I want to ask if there is a way to upgrade my version cakephp 3 beta 1 to 
beta 2. I tried replacing the src folder but i get different errors back. I 
hope there is a easy way and I dont need to replace file by file.

Op zondag 28 september 2014 15:49:02 UTC+2 schreef José Lorenzo:
>
> The CakePHP core team is proud to announce the second beta release for 
> CakePHP 
> 3.0.0 .
> It's been a month since our first beta release, and we are excited by the 
> big welcome the community has given to the new version. All the positive 
> feedback and help has been a great motivation for the core team to work 
> harder on improving the developer experience for 3.0.
>
> This will be the last beta release for 3.0, this means that the API is 
> already stabilizing and we're mostly focusing on polishing the current 
> features, performance optimizations, documentation and quickly solving any 
> issues reported in Github.
>
> We've had a very busy month implementing a few missing features we had in 
> our roadmap and upgrading some of the popular plugins for CakePHP.
>
> Below the list of new features and changes that made it into 3.0.0-beta2:
> DebugKit 
>
> Debugging CakePHP 3.0 applications is even better. The new DebugKit is 
> easier to install, faster and looks gorgeous.
>
> DebugKit is a application toolbar that collects useful statistics about 
> your code such as time and memory, executed queries, log messages and view 
> variables. To install Debugkit just use
>
> composer require cakephp/debug_kit "3.0.*-dev"
>
> And add this line to your bootstrap.php file:
>
> Plugin::load('DebugKit', ['bootstrap' => true]);
>
> If you install a new application using the app skeleton 
> , DebugKit will be automatically 
> installed for you.
> Database Migrations 
>
> Migrations  is now an official 
> CakePHP plugin. It wraps the excellent Phinx  library 
> into a CakePHP shell to avoid repeating configuration strings and add some 
> of the cake experience. A database migration generated by this plugin would 
> look like:
>
>  AbstractMigration {
> /** * Change. */
> public function change() {
> // create the table
> $table = $this->table('users');
> $table->addColumn('id', 'integer')
> ->addColumn('username', 'string')
> ->addColumn('password', 'string')
> ->addColumn('created', 'datetime')
> ->create();
> }
>
> Migrations are reversible. This means that with the same code you can 
> create or rollback the changes done to the database schema.
>
> To install the Migrations plugins run:
>
> composer require cakephp/migrations "dev-master"
>
> And add this line to your bootstrap.php file:
>
> Plugin::load('Migrations');
>
> New Logger interface 
>
> CakePHP has adopted the PSR-3 recommendation for loggers. Now all log 
> engines implement the Prs\Log\LoggerInterface interface. This means that 
> the entire logging system can easily be replaced by other implementations, 
> such as the popular Monolog library .
> Integration Tests and Data Integrity 
>
> Testing controllers has always been problematic. While ControllerTestCase 
> solved some of the problems, we identified this class as a source of 
> problems and confusion among our users. We decided to implement the new 
> IntegrationTestCase class as a way totest all aspects of an HTTP request 
> in your application without much mocking being involved. This should help 
> you improve code quality and ensure that your application and routes are 
> working as expected.
>
> We also made the fixtures system better, allowing developers to define and 
> work with foreign key constraints in their database. The fixtures system 
> will now correctly load all data and enable constraints right before your 
> test code is executed.
> New Bake templates 
>
> With the date for a stable release getting closer and closer we decided to 
> give a new look to default baked applications. Hopefully the new look will 
> feel fresher, more modern, and easier to work with.
> Separate packages 
>
> We've seen an increasing interest in using the new ORM outside the 
> framework or within older CakePHP applications. One of our goals since the 
> start has been making this possible. We have already begun the work to 
> split the framework into various standalone components that can be reused 
> and installed with composer. While the ORM has not yet been extracted into 
> its own repository, most of the necessary pre-requisites are complete. As a 
> product of this work, we have already extracted several components out of 
> the main code base:
>
>- Collections : Provides a set 
>of tools to manipulate arrays or Traversable objects in an efficient and 
>elegant way.
>- Vali

Time Class

2014-10-12 Thread Abdelmajid el Ibrahimi
I read on the website:
 book.cakephp.org/3.0/en/core-libraries/time.html

I need to add 

use Cake\I18n\Time;

But when i do that it doesnt work and says:
*Error: *
Class 'Cake\I18n\Time' not found
If i go look there there is no Time class only a I18n Class.

I need to use DateTime function to get a certain date by giving year week and 
day numbers.

-- 
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: Make select from MYSQL set

2014-09-07 Thread Abdelmajid el Ibrahimi
I checked the book and there wasnt a solution that was ready to use. I
hoped to have a easy form helper everything is very easy in cakephp so i
hoped that this would to. And believe me i read a lot i just begin and i
only ask if i didnt find anything after  a day of searching. I am new to
the mvc and oop framework. I used to do procedural programming. So if I ask
something you can be sure I looked in the api in the book on Google
stackoverflow etc.
Op 7 sep. 2014 08:49 schreef "José Lorenzo" :

> Well, you would do exactly the same thing in CakePHP. Have you checked the
> book? http://book.cakephp.org/2.0/en/index.html
>
> It is a good resource if you are starting with the framework and need to
> do the basic stuff.
>
> On Saturday, September 6, 2014 9:55:09 PM UTC+2, Abdelmajid el Ibrahimi
> wrote:
>>
>> I just query it and then put it in a result and then a while loop and
>> then generate my select.
>>
>> Met vriendelijke groet,
>> A. el Ibrahimi
>> Op 6 sep. 2014 21:44 schreef "José Lorenzo" :
>>
>>> How would you select from a SET column without cake?
>>>
>>> On Saturday, September 6, 2014 6:31:42 PM UTC+2, Abdelmajid el Ibrahimi
>>> wrote:
>>>>
>>>> Can i make a easy select from the SET fields in mysql or do i need to
>>>> write a function to get them.
>>>> CakePHP 3
>>>>
>>>  --
>>> 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 a topic in the
>>> Google Groups "CakePHP" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>> topic/cake-php/DxMd4FZWNuA/unsubscribe.
>>> To unsubscribe from this group and all its topics, 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 a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/DxMd4FZWNuA/unsubscribe.
> To unsubscribe from this group and all its topics, 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: Make select from MYSQL set

2014-09-06 Thread Abdelmajid el Ibrahimi
I just query it and then put it in a result and then a while loop and then
generate my select.

Met vriendelijke groet,
A. el Ibrahimi
Op 6 sep. 2014 21:44 schreef "José Lorenzo" :

> How would you select from a SET column without cake?
>
> On Saturday, September 6, 2014 6:31:42 PM UTC+2, Abdelmajid el Ibrahimi
> wrote:
>>
>> Can i make a easy select from the SET fields in mysql or do i need to
>> write a function to get them.
>> CakePHP 3
>>
>  --
> 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 a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/DxMd4FZWNuA/unsubscribe.
> To unsubscribe from this group and all its topics, 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.


Make select from MYSQL set

2014-09-06 Thread Abdelmajid el Ibrahimi
Can i make a easy select from the SET fields in mysql or do i need to write 
a function to get them.
CakePHP 3

-- 
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: VirtualFields Cakephp 3

2014-09-05 Thread Abdelmajid el Ibrahimi
Okay that was easy. Problem is i find a lot help but cakephp 3 is so 
different than 2.5 even the way you access objects.

Op vrijdag 5 september 2014 19:15:12 UTC+2 schreef Abdelmajid el Ibrahimi:
>
> so i need to make a entity class so i can join 2 fields?
>
> Op vrijdag 5 september 2014 18:27:27 UTC+2 schreef José Lorenzo:
>>
>> Virtual property getters go in the Entity classes not in the Table 
>> classes.
>>
>> On Friday, September 5, 2014 3:57:30 PM UTC+2, Abdelmajid el Ibrahimi 
>> wrote:
>>>
>>> Hello,
>>>
>>> I used the virtualsfield function from the api but it doens't work what 
>>> do i do wrong.
>>>
>>> namespace App\Model\Table;
>>>
>>> use Cake\ORM\Table;
>>> use Cake\Validation\Validator;
>>>
>>> class DocentenTable extends Table {
>>> protected function _getFullName() {
>>> return $this->_properties['voornaam'] . '  ' .
>>> $this->_properties['achternaam'];
>>> }
>>> 
>>> public function initialize(array $config) {
>>> $this->belongsToMany('Klassen');
>>> $this->addBehavior('Timestamp');
>>> }
>>> 
>>> public function validationDefault(Validator $validator) {
>>> $validator
>>> ->notEmpty('voornaam');
>>> return $validator;
>>> }
>>> }
>>>
>>> public function add(){
>>> $this->loadModel('Docenten');
>>> $klas = $this->Klassen->newEntity($this->request->data);
>>> if($this->request->is('post')){
>>> if($this->Klassen->save($klas)){
>>> $this->Flash->success(__('De klas is opgeslagen.'));
>>> return $this->redirect(['action' => 'index']);
>>> }
>>> $this->Flash->error(__('Het toevoegen is niet gelukt.'));
>>> }
>>> $docenten = $this->Docenten->find('list',[
>>> 'idField' => 
>>> 'docent_id',
>>> 'valueField' => 
>>> 'full_name'
>>> ]);
>>> $this->set('docenten',$docenten);
>>> $this->set('klas', $klas);
>>> }
>>>
>>> But the full_name field is empty. 
>>>
>>>

-- 
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: VirtualFields Cakephp 3

2014-09-05 Thread Abdelmajid el Ibrahimi
so i need to make a entity class so i can join 2 fields?

Op vrijdag 5 september 2014 18:27:27 UTC+2 schreef José Lorenzo:
>
> Virtual property getters go in the Entity classes not in the Table classes.
>
> On Friday, September 5, 2014 3:57:30 PM UTC+2, Abdelmajid el Ibrahimi 
> wrote:
>>
>> Hello,
>>
>> I used the virtualsfield function from the api but it doens't work what 
>> do i do wrong.
>>
>> namespace App\Model\Table;
>>
>> use Cake\ORM\Table;
>> use Cake\Validation\Validator;
>>
>> class DocentenTable extends Table {
>> protected function _getFullName() {
>> return $this->_properties['voornaam'] . '  ' .
>> $this->_properties['achternaam'];
>> }
>> 
>> public function initialize(array $config) {
>> $this->belongsToMany('Klassen');
>> $this->addBehavior('Timestamp');
>> }
>> 
>> public function validationDefault(Validator $validator) {
>> $validator
>> ->notEmpty('voornaam');
>> return $validator;
>> }
>> }
>>
>> public function add(){
>> $this->loadModel('Docenten');
>> $klas = $this->Klassen->newEntity($this->request->data);
>> if($this->request->is('post')){
>> if($this->Klassen->save($klas)){
>> $this->Flash->success(__('De klas is opgeslagen.'));
>> return $this->redirect(['action' => 'index']);
>> }
>> $this->Flash->error(__('Het toevoegen is niet gelukt.'));
>> }
>> $docenten = $this->Docenten->find('list',[
>> 'idField' => 
>> 'docent_id',
>> 'valueField' => 
>> 'full_name'
>> ]);
>> $this->set('docenten',$docenten);
>> $this->set('klas', $klas);
>> }
>>
>> But the full_name field is empty. 
>>
>>

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


VirtualFields Cakephp 3

2014-09-05 Thread Abdelmajid el Ibrahimi
Hello,

I used the virtualsfield function from the api but it doens't work what do 
i do wrong.

namespace App\Model\Table;

use Cake\ORM\Table;
use Cake\Validation\Validator;

class DocentenTable extends Table {
protected function _getFullName() {
return $this->_properties['voornaam'] . '  ' .
$this->_properties['achternaam'];
}

public function initialize(array $config) {
$this->belongsToMany('Klassen');
$this->addBehavior('Timestamp');
}

public function validationDefault(Validator $validator) {
$validator
->notEmpty('voornaam');
return $validator;
}
}

public function add(){
$this->loadModel('Docenten');
$klas = $this->Klassen->newEntity($this->request->data);
if($this->request->is('post')){
if($this->Klassen->save($klas)){
$this->Flash->success(__('De klas is opgeslagen.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('Het toevoegen is niet gelukt.'));
}
$docenten = $this->Docenten->find('list',[
'idField' => 
'docent_id',
'valueField' => 
'full_name'
]);
$this->set('docenten',$docenten);
$this->set('klas', $klas);
}

But the full_name field is empty. 

-- 
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: Select Option

2014-09-04 Thread Abdelmajid el Ibrahimi
Opened a bug report #4490
Op 4 sep. 2014 16:09 schreef "José Lorenzo" :

> Could you create a github bug report about this problem in
> https://github.com/cakephp/cakephp/issues ?
>
> It seems like you found something broken.
>
> On Thursday, September 4, 2014 3:10:40 PM UTC+2, Abdelmajid el Ibrahimi
> wrote:
>>
>> Tried it but it doesn't work it says:
>> *Error: * Cannot use object of type Cake\ORM\Query as array
>>
>> I went to use cake php because it is said to be easier to use but i use
>> version 3.0 and all the examples out there are for 1.2 or 2.x.
>>
>> Op donderdag 4 september 2014 15:03:47 UTC+2 schreef scs:
>>>
>>>  You need to either create plural version of docenten in your $this->set
>>>  or in your view in the use
>>>  echo $this->Form->select('docenten', array( 'options'=>$docenten));
>>>
>>  --
> 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 a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/egqBKdozff8/unsubscribe.
> To unsubscribe from this group and all its topics, 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: Select Option

2014-09-04 Thread Abdelmajid el Ibrahimi
Tried it but it doesn't work it says:
*Error: * Cannot use object of type Cake\ORM\Query as array 

I went to use cake php because it is said to be easier to use but i use 
version 3.0 and all the examples out there are for 1.2 or 2.x.

Op donderdag 4 september 2014 15:03:47 UTC+2 schreef scs:
>
>  You need to either create plural version of docenten in your $this->set
>  or in your view in the use 
>  echo $this->Form->select('docenten', array( 'options'=>$docenten)); 
>

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


Select Option

2014-09-03 Thread Abdelmajid el Ibrahimi
I have a controller where i use this statement:
$this->set('docenten',$this->Docenten->find('list',array('fields' => 
array('Docenten.voornaam';

Then in my view i use:
echo $this->Form->select('docenten');

But it wont populate the list, What am I doing wrong?

I want a selectbox with value=id and the name = voornaam.

-- 
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-09-01 Thread Abdelmajid el Ibrahimi
Thank you very much that solved my problem. Didn't now anything about a 
inflector.

Op maandag 1 september 2014 13:10:10 UTC+2 schreef Stephen S:
>
> It'd make more sense to create custom Inflection rules rather than 
> translating the models into english.
>
>
> http://book.cakephp.org/3.0/en/core-utility-libraries/inflector.html#inflection-configuration
>
>
> On 1 September 2014 12:08, Thomas von Hassel  > wrote:
>
>> https://gist.github.com
>>
>> On 01 Sep 2014, at 13:08, Abdelmajid el Ibrahimi > > wrote:
>>
>> What is a gist?
>>
>> Met vriendelijke groet,
>> A. el Ibrahimi
>> Op 1 sep. 2014 13:04 schreef "Thomas von Hassel" > >:
>>
>>> maybe you should post a gist with your code ..
>>>
>>>
>>> On 01 Sep 2014, at 13:02, Abdelmajid el Ibrahimi >> > wrote:
>>>
>>> I know what you mean but than i need to translate all my fields to show 
>>> it to the users. Now i dont need to do anything the system generates the 
>>> field and table names in my view in dutch because that is how my database 
>>> model is build. Well it is solved now and i get what the problem is. 
>>> Because the verzorgers table is not a problem and the key is searched for 
>>> is verzorger. Because in english the s is for plural so he removes the s 
>>> and knows that it is the singular form. Where can I find the core orm file 
>>> in the system.
>>>
>>> Met vriendelijke groet,
>>> A. el Ibrahimi
>>> Op 1 sep. 2014 12:56 schreef "Thomas von Hassel" >> >:
>>>
>>>> Im not talking about what the users see, only what the models are 
>>>> called internally
>>>>
>>>> /thomas
>>>>
>>>>
>>>> On 01 Sep 2014, at 12:55, Abdelmajid el Ibrahimi >>> > wrote:
>>>>
>>>> I have used it but it still didnt solve the problem. And to make 
>>>> everything in english is double work for me because then i will need to 
>>>> translate everything. For a app that is only needed in holland.
>>>>
>>>> Met vriendelijke groet,
>>>> A. el Ibrahimi
>>>> Op 1 sep. 2014 09:14 schreef "Thomas von Hassel" >>> >:
>>>>
>>>>> If you use $this->primaryKey($myKey) in your Table model, thats not in 
>>>>> the core file and a perfectly valid to do.
>>>>>
>>>>> But, i would mention that when designing your app, it’s better to keep 
>>>>> everything (model names etc) in english so the inflector knows how 
>>>>> everything is named.
>>>>>
>>>>> /thomas
>>>>>
>>>>>
>>>>> On 01 Sep 2014, at 01:34, Abdelmajid el Ibrahimi >>>> > wrote:
>>>>>
>>>>> i just changed the key to leerlingen_id and it works. Just a 
>>>>> workaround but i dont want to screw with the core files. CakePHP is 
>>>>> supposed to be easy to use that means that if i follow the tutorial it 
>>>>> should do what is says.
>>>>>
>>>>> Op zondag 31 augustus 2014 21:35:59 UTC+2 schreef 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:
>>>>>>>>>
>>>

Re: BelongsToMany model

2014-09-01 Thread Abdelmajid el Ibrahimi
What is a gist?

Met vriendelijke groet,
A. el Ibrahimi
Op 1 sep. 2014 13:04 schreef "Thomas von Hassel" :

> maybe you should post a gist with your code ..
>
>
> On 01 Sep 2014, at 13:02, Abdelmajid el Ibrahimi 
> wrote:
>
> I know what you mean but than i need to translate all my fields to show it
> to the users. Now i dont need to do anything the system generates the field
> and table names in my view in dutch because that is how my database model
> is build. Well it is solved now and i get what the problem is. Because the
> verzorgers table is not a problem and the key is searched for is verzorger.
> Because in english the s is for plural so he removes the s and knows that
> it is the singular form. Where can I find the core orm file in the system.
>
> Met vriendelijke groet,
> A. el Ibrahimi
> Op 1 sep. 2014 12:56 schreef "Thomas von Hassel" :
>
>> Im not talking about what the users see, only what the models are called
>> internally
>>
>> /thomas
>>
>>
>> On 01 Sep 2014, at 12:55, Abdelmajid el Ibrahimi 
>> wrote:
>>
>> I have used it but it still didnt solve the problem. And to make
>> everything in english is double work for me because then i will need to
>> translate everything. For a app that is only needed in holland.
>>
>> Met vriendelijke groet,
>> A. el Ibrahimi
>> Op 1 sep. 2014 09:14 schreef "Thomas von Hassel" :
>>
>>> If you use $this->primaryKey($myKey) in your Table model, thats not in
>>> the core file and a perfectly valid to do.
>>>
>>> But, i would mention that when designing your app, it’s better to keep
>>> everything (model names etc) in english so the inflector knows how
>>> everything is named.
>>>
>>> /thomas
>>>
>>>
>>> On 01 Sep 2014, at 01:34, Abdelmajid el Ibrahimi 
>>> wrote:
>>>
>>> i just changed the key to leerlingen_id and it works. Just a workaround
>>> but i dont want to screw with the core files. CakePHP is supposed to be
>>> easy to use that means that if i follow the tutorial it should do what is
>>> says.
>>>
>>> Op zondag 31 augustus 2014 21:35:59 UTC+2 schreef 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 {
>>>>>&

Re: BelongsToMany model

2014-09-01 Thread Abdelmajid el Ibrahimi
I know what you mean but than i need to translate all my fields to show it
to the users. Now i dont need to do anything the system generates the field
and table names in my view in dutch because that is how my database model
is build. Well it is solved now and i get what the problem is. Because the
verzorgers table is not a problem and the key is searched for is verzorger.
Because in english the s is for plural so he removes the s and knows that
it is the singular form. Where can I find the core orm file in the system.

Met vriendelijke groet,
A. el Ibrahimi
Op 1 sep. 2014 12:56 schreef "Thomas von Hassel" :

> Im not talking about what the users see, only what the models are called
> internally
>
> /thomas
>
>
> On 01 Sep 2014, at 12:55, Abdelmajid el Ibrahimi 
> wrote:
>
> I have used it but it still didnt solve the problem. And to make
> everything in english is double work for me because then i will need to
> translate everything. For a app that is only needed in holland.
>
> Met vriendelijke groet,
> A. el Ibrahimi
> Op 1 sep. 2014 09:14 schreef "Thomas von Hassel" :
>
>> If you use $this->primaryKey($myKey) in your Table model, thats not in
>> the core file and a perfectly valid to do.
>>
>> But, i would mention that when designing your app, it’s better to keep
>> everything (model names etc) in english so the inflector knows how
>> everything is named.
>>
>> /thomas
>>
>>
>> On 01 Sep 2014, at 01:34, Abdelmajid el Ibrahimi 
>> wrote:
>>
>> i just changed the key to leerlingen_id and it works. Just a workaround
>> but i dont want to screw with the core files. CakePHP is supposed to be
>> easy to use that means that if i follow the tutorial it should do what is
>> says.
>>
>> Op zondag 31 augustus 2014 21:35:59 UTC+2 schreef 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
>>>>>

Re: BelongsToMany model

2014-09-01 Thread Abdelmajid el Ibrahimi
I have used it but it still didnt solve the problem. And to make everything
in english is double work for me because then i will need to translate
everything. For a app that is only needed in holland.

Met vriendelijke groet,
A. el Ibrahimi
Op 1 sep. 2014 09:14 schreef "Thomas von Hassel" :

> If you use $this->primaryKey($myKey) in your Table model, thats not in the
> core file and a perfectly valid to do.
>
> But, i would mention that when designing your app, it’s better to keep
> everything (model names etc) in english so the inflector knows how
> everything is named.
>
> /thomas
>
>
> On 01 Sep 2014, at 01:34, Abdelmajid el Ibrahimi 
> wrote:
>
> i just changed the key to leerlingen_id and it works. Just a workaround
> but i dont want to screw with the core files. CakePHP is supposed to be
> easy to use that means that if i follow the tutorial it should do what is
> says.
>
> Op zondag 31 augustus 2014 21:35:59 UTC+2 schreef 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

Re: BelongsToMany model

2014-09-01 Thread Abdelmajid el Ibrahimi
i just changed the key to leerlingen_id and it works. Just a workaround but 
i dont want to screw with the core files. CakePHP is supposed to be easy to 
use that means that if i follow the tutorial it should do what is says.

Op zondag 31 augustus 2014 21:35:59 UTC+2 schreef 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: 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.


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.