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

Thursday, February 3, 2022

[FIXED] How to use 'AS' in cakephp 4 query?

 February 03, 2022     cakephp, php     No comments   

Issue

How to add AS in cake php query?

$table = $this
->find()
->select(['id', 'fname AS first_name'])

When i run it "check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AS "

enter image description here


Solution

Simple try:

$this
->find()
->select(['id'])
->select(['fname' => 'first_name']); // SELECT first_name AS fname

and read:

https://book.cakephp.org/4/en/orm/query-builder.html#selecting-data



Answered By - Salines
  • 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