# |
Sep 3rd 2019, 01:11 |
cnizzardini |
gl |
# |
Sep 3rd 2019, 01:11 |
FrostCandy |
Woohoo saving a new entity worked. |
# |
Sep 3rd 2019, 01:07 |
FrostCandy |
testing new entity, and save / updating now and then i should be finally done. |
# |
Sep 3rd 2019, 01:07 |
cnizzardini |
I think you can do $resourcelog->find()->get('1c') or something, check the docs |
# |
Sep 3rd 2019, 01:07 |
FrostCandy |
That seems like it would work as well, but the ById worked too |
# |
Sep 3rd 2019, 01:07 |
cnizzardini |
I usually write stuff like that, forgoing the magic stuff |
# |
Sep 3rd 2019, 01:07 |
cnizzardini |
$resourcelog->find()->where(['id' => '1c'])->first(); |
# |
Sep 3rd 2019, 01:05 |
FrostCandy |
$query = $resourcelog->findById('1-1-1'); seems to have worked |
# |
Sep 3rd 2019, 01:04 |
FrostCandy |
but that blows up |
# |
Sep 3rd 2019, 01:04 |
FrostCandy |
find pulls everythign though right? I want to pull by ID which is a charcter string - $query = $resourcelog->find('1c'); |
# |
Sep 3rd 2019, 01:03 |
FrostCandy |
i suspect things will be good now thanks , newEntity and save hopefully fine too |
# |
Sep 3rd 2019, 01:02 |
FrostCandy |
at least the query part |
# |
Sep 3rd 2019, 01:02 |
FrostCandy |
yay it worked :D |
# |
Sep 3rd 2019, 01:02 |
cnizzardini |
If I interviewed someone and I saw them using any framework far away from how it was designed, that would be a red flag to me |
# |
Sep 3rd 2019, 01:02 |
cnizzardini |
If that doesn't work post your code or error |
# |
Sep 3rd 2019, 01:01 |
cnizzardini |
save() works the same |
# |
Sep 3rd 2019, 01:01 |
cnizzardini |
newEntity() and patchEntity work the same |
# |
Sep 3rd 2019, 01:00 |
cnizzardini |
use TableRegistry |
# |
Sep 3rd 2019, 01:00 |
cnizzardini |
yes |
# |
Sep 3rd 2019, 01:00 |
FrostCandy |
^^ That ? |
# |
Sep 3rd 2019, 01:00 |
cnizzardini |
TableRegistry::getTableLocator()->get('TableName'); |
# |
Sep 3rd 2019, 00:59 |
FrostCandy |
use Cake\ORM\TableRegistry; |
# |
Sep 3rd 2019, 00:59 |
FrostCandy |
what use do you use for the 3.7 ? |
# |
Sep 3rd 2019, 00:58 |
cnizzardini |
works for me in 3.7 |
# |
Sep 3rd 2019, 00:58 |
cnizzardini |
should work fine on 3.8 |
# |
Sep 3rd 2019, 00:58 |
cnizzardini |
$articlesTable = TableRegistry::getTableLocator()->get('Articles'); |
# |
Sep 3rd 2019, 00:58 |
FrostCandy |
well old style didnt work for me. I'll try again. thanks for the help. |
# |
Sep 3rd 2019, 00:58 |
FrostCandy |
ok , i'll try it agai. I'm doing a test for a company that doesn't evne use this framework and I've never touched this framework but their HR Department knows best :D |
# |
Sep 3rd 2019, 00:57 |
cnizzardini |
But use the new style |
# |
Sep 3rd 2019, 00:57 |
cnizzardini |
The old style will still work, it just throws an E_USER_DEPRECATED |
# |
Sep 3rd 2019, 00:57 |
FrostCandy |
oh ok |
# |
Sep 3rd 2019, 00:57 |
FrostCandy |
oh and the secon done is what i want ? |
# |
Sep 3rd 2019, 00:57 |
cnizzardini |
For >= 3.7 use $articlesTable = TableRegistry::getTableLocator()->get('Articles'); |
# |
Sep 3rd 2019, 00:57 |
cnizzardini |
$articlesTable = TableRegistry::get('Articles'); vs $articlesTable = TableRegistry::getTableLocator()->get('Articles'); |
# |
Sep 3rd 2019, 00:57 |
FrostCandy |
Well where do i find the >=3.7 doc |
# |
Sep 3rd 2019, 00:56 |
cnizzardini |
The man difference is just how you get grab the Table |
# |
Sep 3rd 2019, 00:56 |
cnizzardini |
But if you are going to do that, be sure to still bind your parameters |
# |
Sep 3rd 2019, 00:56 |
cnizzardini |
Use the framework as intended |
# |
Sep 3rd 2019, 00:56 |
FrostCandy |
$results = $connection->execute( .... |
# |
Sep 3rd 2019, 00:56 |
cnizzardini |
No don't do that |
# |
Sep 3rd 2019, 00:56 |
FrostCandy |
Thanks it's too hard right now to bother learning it. I'll just use the directy queries, it's much easier to understand. |