PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 16, 2022

[FIXED] how to select all records from one table and some from another table in cakephp 3.6

 February 16, 2022     cakephp, cakephp-3.0, mysql, php     No comments   

Issue

SELECT myTable.*, otherTable.foo, otherTable.bar...

how can we write above query in cakephp ? I tried this but didn't work.

$data = $this->Articles->find()->select(['Articles.*','Categories.name'])->innerJoineWith('Categories');

It giving me error near SELECT Fees.* ASFees__*.

So instead of that, I have to write all columns of the Article Table.

$data = $this->Articles->find()->select(['Articles.id','Articles.name','Articles.title','Articles.description','Categories.name'])->innerJoineWith('Categories');

is there any solution in cakephp? please tell me. Thank You.


Solution

$data = $this->Articles->find()
        ->select($this->Articles)
        ->select(['Categories.name'])
        ->innerJoineWith('Categories');


Answered By - 26vivek
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing