Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7985211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:29:42+00:00 2026-06-04T11:29:42+00:00

hi all I’m trying to search a database for a username using cakephp, the

  • 0

hi all I’m trying to search a database for a username using cakephp, the username isnt the primary key in the database but it must be unique. here is the code I have for the search function but cake does not like it.

    function index(){
    $this->User->recursive = 0;
    if ($this->data['users']['username']) { 
$this->set('users',  
$this->paginate('users', array('or' => array('users.username LIKE' => '%' .  )));
    else { 
$this->set('users', $this->paginate()); 
        }
        }
    }

the database contains a id(the primary key) and a username. The goal of this is to send a friend request. User searches the username and then if the username is there, the other user will receive their request in a relationship inbox and can select ‘yes’ or ‘no’.

the other thing is, if the username exists I want the data to be stored in a table called users_users – i realize i dont have any code for what to do once the search has happened. but I am pulling my hair out trying to figure this out as their doesnt seem to be many tutorials on the web for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:29:43+00:00Added an answer on June 4, 2026 at 11:29 am

    Make sure your usernames are unique by validating it when they’re entered.
    http://book.cakephp.org/2.0/en/models/data-validation.html

    I’m not sure, but this users.username looks like you’re using the username as foreign key in the jointable!? Thats totally wrong.

    Even if it would be then the notation is wrong and does not follow the CakePHP standards and won’t work. It should be User.username then.

    I would suggest you to start over with the blog tutorial for CakePHP and read the book.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I'm using the code that facebook provides but here is what I'm using:
all, I am trying to multiply a matrix to a vector in OpenGL, but
All I am trying to do is take a standard range on an excel
All the examples I've come across using Google Maps API seem to show a
All of the examples I've seen of using yield return x; inside a C#
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
All, I am building a small site using PHP. In the site, I receive
All, I am trying to create a table to receive user inputs (UGC). This
All, I'm using wordpress with this and for some reason the eventDrop stopped working.
All, I'm using Facebook Connect (JS SDK) to authenticate a user to my site.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.