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

Wednesday, January 19, 2022

[FIXED] Cakephp how to find id by value

 January 19, 2022     cakephp, cakephp-2.0, php, sql, syntax     No comments   

Issue

How can i write this syntax in CakePHP:

Example:

$userID = "SELECT user_id FROM customers WHERE phone = '88888888' ";

like:

$user = $this->Customer->find('first', array('conditions' => array(
             'Customer.user_id WHERE phone' => '88888888')));

I would like to find user_id where the phone number have a specific value


Solution

What you're trying to do is really basic, you should read the documentation for the find() function.

$user = $this->Customer->find('first',  array(
    // You specify which field(s) you want
    'fields' => array('user_id'),
    // You add the condition(s)
    'conditions' => array('Customer.phone' => '88888888'),
));


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