# |
Oct 4th 2016, 06:12 |
ra7bi |
the pdf file shouldn't be generated |
# |
Oct 4th 2016, 06:12 |
ra7bi |
so if there is no data |
# |
Oct 4th 2016, 06:12 |
ra7bi |
This query is for generating PDF file |
# |
Oct 4th 2016, 06:12 |
ndm |
depends on what for you need that info |
# |
Oct 4th 2016, 06:11 |
ra7bi |
so what is the best way to check if the query returning row or it's empty , |
# |
Oct 4th 2016, 06:11 |
ksandeep_ |
Hi, how i can set layout for admin from AppController. $this->viewBuilder()->layout('admin'); is not working for me in initialize method. |
# |
Oct 4th 2016, 06:10 |
ndm |
I probably shouldn't have said "_nothing_", as in that case it will throw an exception |
# |
Oct 4th 2016, 06:09 |
ra7bi |
Okay so it's okay to check like this if($participant) { |
# |
Oct 4th 2016, 06:09 |
ndm |
`get()` will either return 1 record, or nothing, that's why... |
# |
Oct 4th 2016, 06:09 |
ra7bi |
this code giving me Error ``` Error: Call to undefined method App\Model\Entity\Participant::count() ``` |
# |
Oct 4th 2016, 06:08 |
slackebot1 |
$totalResult = $participant->count(); ``` |
# |
Oct 4th 2016, 06:08 |
ra7bi |
``` // Check if the person is okay . $participants = TableRegistry::get('Participants'); $participant = $participants->get($this->request->data(['participant_id']),[ 'contain' => ['Distributors', 'Events','Payments'], 'conditions' => [ 'Events.start_date >= NOW()', //'distributors.id'=>$this->Auth->user('distributor_id') ] |
# |
Oct 4th 2016, 06:08 |
ra7bi |
i want to know how many records returning from the query |
# |
Oct 4th 2016, 06:08 |
ra7bi |
why i cant use count method with $query->get |
# |
Oct 4th 2016, 06:08 |
ra7bi |
hi |
# |
Oct 4th 2016, 04:07 |
ndm |
http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#countercache-cache-your-count |
# |
Oct 4th 2016, 04:07 |
ndm |
However you could write that query using joins too... or use a counter cache |
# |
Oct 4th 2016, 04:06 |
ndm |
@justrohu Then you're going to have a bad time in case `fields` doesn't accept (subquery) expressions (haven't used 2.x for quite some now, not sure if it works): http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#sub-queries |
# |
Oct 4th 2016, 04:03 |
justrohu |
@ndm: what if I want to run subquery like select user.id, (select count(*) from cars where cars.user_id = users.id) as car_count from users |
# |
Oct 4th 2016, 04:00 |
justrohu |
@ndm: Thank you |
# |
Oct 4th 2016, 03:59 |
slackebot1 |
association conditions in case you've defined some in your association setup. |
# |
Oct 4th 2016, 03:59 |
ndm |
@justrohu You must for `hasMany` and `hasAndBelongsToMany` associations, as they are being retrieved in a separate query if you include them via `contain` or an according `recursive` level. For `belongsTo` and `hasOne` it should be possible to just include the associations via `contain` or `recursive` as they are being retrieved in the main query (they may not use the `INNER` join type though). Also don't forget that you may have to include poss |
# |
Oct 4th 2016, 03:50 |
justrohu |
@ndm : thank you, please correct me if I am wrong here, "For data with conditions on associated hasMany table I must / always have to use join" |
# |
Oct 4th 2016, 03:47 |
savant |
@backstageel any reason why you requested the github integration? |
# |
Oct 4th 2016, 03:46 |
slackebot1 |
<http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#complex-find-conditions |
# |
Oct 4th 2016, 03:46 |
ndm |
@justrohu You can't refer to something that doesn't exist in your query, you need to join the car table in. http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#joining-tables> Use an `INNER` join, and in case a user can have multiple cars of the same name, don't forget to group by the users primary key (or do a distint select on it) in order to avoid getting duplicate results. |
# |
Oct 4th 2016, 03:38 |
justrohu |
any body please help me |
# |
Oct 4th 2016, 03:35 |
justrohu |
Hello all, I have users hasmany association with cars table... now I want to get all the user who have Ferrari Elemento ... How do I write query for this .. I did try doing $this->User->find('all',['conditions'=>['Car.name' => 'Ferrari Elemento' ]]); but this is giving me invalid Car.name column database error |
# |
Oct 4th 2016, 03:30 |
cjohnson |
Is there a way to call callbacks for the Expandable behavior without calling the callbacks for the model itself? specifically when saving |
# |
Oct 4th 2016, 02:11 |
froodley |
there's only one entry in the routing, Router::connect('/', array('controller' => 'users', 'action' => 'login')); |
# |
Oct 4th 2016, 02:11 |
froodley |
this is cake 2 |
# |
Oct 4th 2016, 02:10 |
froodley |
like if I go <domain>/asdf, I get AsdfController could not be found. |
# |
Oct 4th 2016, 02:10 |
froodley |
instead of throwing 404s, one of my apps is throwing 500s when it can't find a controller |
# |
Oct 4th 2016, 02:10 |
froodley |
Hello... having a strange problem... |
# |
Oct 4th 2016, 01:49 |
waspinator |
and seemingly only in the shell. I'm probably doing something different than when I'm calling it from a controller |
# |
Oct 4th 2016, 01:48 |
waspinator |
it's just a really strange bug, that it works as long as you do it every 1-2 minutes. any faster and it fails |
# |
Oct 4th 2016, 01:48 |
waspinator |
yeah that makes sense. I'll look into it and maybe try other html to pdf options that cakepdf supports. |
# |
Oct 4th 2016, 01:46 |
ndm |
@waspinator That's a kinda wkhtmltopdf specific problem, you may get better help if you isolate the problem and ask wkhtmltopdf folks for help. Given the stuff you can find around the net, this is likely related to (external) assets in one way or another. https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2051 |
# |
Oct 4th 2016, 01:35 |
waspinator |
good night |
# |
Oct 4th 2016, 01:34 |
robodna |
Yes, I'm asking for the purpose of discovering the lowest common denominator for my API code. |
# |
Oct 4th 2016, 01:34 |
waspinator |
http://discourse.cakephp.org/t/cakepdf-not-working-in-a-shell/1275 |