# |
Nov 29th 2017, 21:05 |
saeideng |
inoas |
# |
Nov 29th 2017, 21:05 |
saeideng |
https://api.cakephp.org/3.5/source-class-Cake.Datasource.QueryTrait.html#402-421 |
# |
Nov 29th 2017, 21:05 |
inoas |
saeideng you can use formatResults to get the first item only instead of list of 1 items |
# |
Nov 29th 2017, 21:05 |
saeideng |
$query->select(['id', 'username'])->first(); |
# |
Nov 29th 2017, 21:04 |
inoas |
saeideng yeah true |
# |
Nov 29th 2017, 21:04 |
joopm |
and in my case no other |
# |
Nov 29th 2017, 21:04 |
joopm |
or is there sometinh like matching but returns only the first? |
# |
Nov 29th 2017, 21:03 |
joopm |
and its part of a matching |
# |
Nov 29th 2017, 21:03 |
joopm |
i want only the first one |
# |
Nov 29th 2017, 21:02 |
saeideng |
this returns array of result |
# |
Nov 29th 2017, 21:02 |
joopm |
but using ->first() there |
# |
Nov 29th 2017, 21:02 |
joopm |
this is the condition for the query |
# |
Nov 29th 2017, 21:02 |
joopm |
->where(['AND'=>[['Applications.state_id'=>2],['user_id'=>$this->Auth->User('id')]]]) //here does not works first();} |
# |
Nov 29th 2017, 21:02 |
joopm |
i know that first return result not query |
# |
Nov 29th 2017, 21:01 |
joopm |
Query builder for association "Applications" did not return a query |
# |
Nov 29th 2017, 21:01 |
saeideng |
first return result not query |
# |
Nov 29th 2017, 21:01 |
joopm |
first would be good but its says no query return |
# |
Nov 29th 2017, 21:00 |
saeideng |
first returns "item" |
# |
Nov 29th 2017, 20:59 |
saeideng |
limit returns [0 => item] |
# |
Nov 29th 2017, 20:59 |
saeideng |
limit and first different |
# |
Nov 29th 2017, 20:58 |
saeideng |
inoas |
# |
Nov 29th 2017, 20:55 |
inoas |
first() will execute which seems is not what you want (you want to return the query object) |
# |
Nov 29th 2017, 20:55 |
inoas |
joopm limit(1) |
# |
Nov 29th 2017, 20:55 |
saeideng |
or limit(1) |
# |
Nov 29th 2017, 20:54 |
saeideng |
first() |
# |
Nov 29th 2017, 20:54 |
obinoob |
joopm: you only need to save one registry right? |
# |
Nov 29th 2017, 20:53 |
joopm |
but i dont need to get the first element of array i just need one element |
# |
Nov 29th 2017, 20:53 |
saeideng |
and save with save entities() |
# |
Nov 29th 2017, 20:53 |
saeideng |
create entity |
# |
Nov 29th 2017, 20:53 |
joopm |
->limit(1) would work |
# |
Nov 29th 2017, 20:53 |
obinoob |
also here https://book.cakephp.org/3.0/en/orm/validation.html#using-different-validators-per-association |
# |
Nov 29th 2017, 20:51 |
obinoob |
so i think I've found my answer https://book.cakephp.org/3.0/en/orm/saving-data.html#saving-associations |
# |
Nov 29th 2017, 20:50 |
obinoob |
as my nick implies I am a noob ;) |
# |
Nov 29th 2017, 20:50 |
joopm |
i only need this exactly |
# |
Nov 29th 2017, 20:50 |
obinoob |
saeideng I am a "WIP" lol learning everything by my own I guess that would be easier to seat on a class room but not possible |
# |
Nov 29th 2017, 20:49 |
joopm |
->where(['AND'=>[['Applications.state_id'=>2],['user_id'=>$this->Auth->User('id')]]]) //here does not works first();} |
# |
Nov 29th 2017, 20:49 |
joopm |
{return $q |
# |
Nov 29th 2017, 20:49 |
saeideng |
`$conn->execute('INSERT into addresses ` |
# |
Nov 29th 2017, 20:49 |
joopm |
do you that how can i get the first result from the following querry |
# |
Nov 29th 2017, 20:48 |
joopm |
good evening to all community members |
# |
Nov 29th 2017, 20:48 |
saeideng |
obinoob |