0
$options = array(
    'fields' => array(
        'item_requirements.*',
        'COUNT(`item_requirements`.`quantity_required`) as count'
    ),
    'joins' => array(
        'INNER JOIN `items` AS item_requirements ON `item_requirements`.`item_id` = `items`.`id`'
    ),
    'group' => '`item_requirements`.`item_id`',
    'contain' => array(
        'items' => array('fields' => array('name', 'specification'))
    )
);
$query = $this->Indents->ItemRequirements->find('all', $options);

Error: SQLSTATE[42601]: Syntax error: 7 ERROR: zero-length delimited identifier at or near """" LINE 1: ...item_requirements`.`quantity_required`) AS "counts"" AS "COU... ^

the above error occurs.. any solutions to solve this..

ndm
  • 59,784
  • 9
  • 71
  • 110
  • Can you include the actual SQL query that this generates? – Greg Schmidt Nov 22 '18 at 18:01
  • query select BB.id item_id, BB.code || '-' || BB.sub_code || '-' || BB.name || '-' || BB.specification item_details, AA.quantity_required consolidated_quantity from (select a.item_id, sum(a.quantity_required) quantity_required from tms.item_requirements a group by a.item_id) AA inner join (select b.id, b.code, b.sub_code, b.name, b.specification, b.unit_qty_code_id from tms.items b) BB on BB.id=AA.item_id ; – Meenatchi P Nov 23 '18 at 07:12
  • Have you tried replacing the alias `count` by someting less ambigious ? – code-kobold Nov 23 '18 at 08:55
  • Is the query you've shared here exactly what it generates? I don't see how all the AA and BB came to be, from the code you posted. If you've made edits before posting, those might accidentally change something. – Greg Schmidt Nov 23 '18 at 16:14
  • This is the query for the above case (select a.item_id, sum(a.quantity_required) quantity_required from tms.item_requirements a group by a.item_id) AA inner join (select b.id, b.code, b.sub_code, b.name, b.specification, b.unit_qty_code_id from tms.items b) – Meenatchi P Nov 24 '18 at 13:00

1 Answers1

0

The issue is with item_requirements.*. .* is not supported by cake ORM.

You can use ->autoFields(true) option. Refer this answer

aravind_s
  • 106
  • 8