# |
Jul 22nd 2017, 17:07 |
hmic |
you can make your entity classes use your own entity trait instead of the cakephp provided one easily. |
# |
Jul 22nd 2017, 17:06 |
hmic |
iblumbo: have you worked with the magic getters and setter in php before? - if not, read the php manual about them, there are examples provided. you can just return NULL from a getter or raise an exception e.g. which basically makes the var private. |
# |
Jul 22nd 2017, 17:05 |
iblumbo |
I checked the EntityTrait and I did see the _set method, but I've got stuck in where to override it and how make them look private :/ |
# |
Jul 22nd 2017, 16:56 |
hmic |
with the __get and __set approach, you can make them look private by default, easily |
# |
Jul 22nd 2017, 16:56 |
hmic |
this said, it looks kind of feasable to make them private in cake - but - you would need to define all the classvars in this case, which is not required now. |
# |
Jul 22nd 2017, 16:55 |
hmic |
check the php magic __get and __set methods, you will find information on google on how to utilize them to make class variables *look* private, as you implement getters and setters implicitely with utilizing them, you would not need not provide real getters and setters. but you can! this is the approach cakephp and the entity classes use btw! check the source! |
# |
Jul 22nd 2017, 16:53 |
iblumbo |
I'll try to figure it out. thanks for the feedback hmic :) |
# |
Jul 22nd 2017, 16:53 |
iblumbo |
yeah yeah I know its an overhead, it's just for one academic assignment haha |
# |
Jul 22nd 2017, 16:44 |
hmic |
yeah, play things you can't on workdays |
# |
Jul 22nd 2017, 16:43 |
birdy247 |
I am working with Guzzle |
# |
Jul 22nd 2017, 16:43 |
birdy247 |
experimenting! |
# |
Jul 22nd 2017, 16:43 |
birdy247 |
I like staurdays for this |
# |
Jul 22nd 2017, 16:43 |
birdy247 |
:slightly_smiling_face: |
# |
Jul 22nd 2017, 16:43 |
hmic |
birdy247: not working really, just in the office, playing with alexa and building a philips hue emulator gadget at the moment |
# |
Jul 22nd 2017, 16:42 |
hmic |
entities are supposed to be as lightweight as possible (value objects). you do have getter/setters available though. you can overwrite whatever you want with specifying your own getter/setter methods technically making the properties private. but i dont see any use for that and it introduces lots of (unneccessary) additional overhead |
# |
Jul 22nd 2017, 16:42 |
birdy247 |
saturday working? |
# |
Jul 22nd 2017, 16:41 |
birdy247 |
Hey hmic |
# |
Jul 22nd 2017, 16:41 |
hmic |
still: whats the reasoning? |
# |
Jul 22nd 2017, 16:39 |
iblumbo |
Got it! Do you think there's a way to make every entity property private by default and create getter and setters to them in cake v3 |
# |
Jul 22nd 2017, 16:17 |
hmic |
you can add private methods and variables to an entity. they will not get persisted to the db or set though |
# |
Jul 22nd 2017, 16:16 |
hmic |
iblumbo, whats the reasoning? |
# |
Jul 22nd 2017, 16:09 |
iblumbo |
is it possible to encapsulate (make private) the properties from an Entity ? |
# |
Jul 22nd 2017, 13:15 |
slackebot |
$name)); $conds['OR'][] = $concat; |
# |
Jul 22nd 2017, 13:15 |
itamer |
My broken code so far $conds['OR']['Memberships.name'] = $name; //$conds['OR']["CONCAT(Individuals.firstname,' ',Individuals.lastname)"] = $name; $query = $this->Leads->find()->innerJoinWith('Individuals'); $concat = $query->func()->concat('Individuals.firstname' => 'identifier',' ','Individuals.lastname' => 'identifier']); debug($concat); //debug($query->like($ |
# |
Jul 22nd 2017, 13:13 |
itamer |
I'm going to need to change the way I run my queries. For the complex stuff I generally work through all the logic and build up $conds as necessary, $fields etc and then run it. This version seems to want a query written for each possible combination but maybe I'm missing the flexibility of it because I'm still way, way too new. |
# |
Jul 22nd 2017, 12:49 |
birdy247 |
should I expect table object to be called in the through model? |
# |
Jul 22nd 2017, 12:49 |
birdy247 |
If I am saving a belongsToMany with the "through" option |
# |
Jul 22nd 2017, 12:41 |
Guest68527 |
so A is not directly belong to C but using AB it belongs to ABC |
# |
Jul 22nd 2017, 12:40 |
Guest68527 |
AB belong to many C by ABC table |
# |
Jul 22nd 2017, 12:40 |
Guest68527 |
so A belongs to many B using table AB |
# |
Jul 22nd 2017, 12:39 |
Guest68527 |
Thanks Admad, but my problem is little different. While entering a course, first user can create course, the register course for each session. that register course can be available in multiple language |
# |
Jul 22nd 2017, 12:35 |
itamer |
@admad thank you though, I appreciate having a prompt response |
# |
Jul 22nd 2017, 12:35 |
itamer |
midnight might not be the best time to be reading that. Very diff from v1.2 and v2. I've got my work cut out for me! |
# |
Jul 22nd 2017, 12:35 |
admad |
Guest68527: https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#filtering-by-associated-data |
# |
Jul 22nd 2017, 12:32 |
Guest68527 |
admad, can you plz help me |
# |
Jul 22nd 2017, 12:28 |
itamer |
The other thing people will enter is "Sarah Smith and John Doe" which may actually be a match for another field (but not this one) |
# |
Jul 22nd 2017, 12:28 |
admad |
https://book.cakephp.org/3.0/en/orm/query-builder.html#using-sql-functions |
# |
Jul 22nd 2017, 12:27 |
itamer |
I'll go back to that if I have to |
# |
Jul 22nd 2017, 12:27 |
itamer |
It's a quick and easy form for people to enter but I've wanted to avoid having to work out if "Sarah de Smith" or "Sarah van Smith" or "Sarah Jane Smith" has been entered - the concat worked just fine before but we've upgraded. |
# |
Jul 22nd 2017, 12:25 |
admad |
@itamer why concat instead of just using firstname => 'Sarah' and 'lastname' => 'Smith' in conditions? |
# |
Jul 22nd 2017, 12:21 |
itamer |
I want to add this to my $conds array and pass it into the query 'CONCAT(Individuals.firstname,' ',Individuals.lastname)' => 'Sarah Smith' but when it gets parsed into the query it comes out as CONCAT(Individuals.firstname,' ',individuals.lastname) :c1 and fails because there is no operator between the concat statement and the variable I'm guessing it's the concat that throws it out. Any workarounds? |