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

  • Home
  • SEARCH
  • 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 8781571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:20:16+00:00 2026-06-13T20:20:16+00:00

I have three Models User Note ( Same as Post ) Friendship I am

  • 0

I have three Models

  1. User
  2. Note ( Same as Post )
  3. Friendship

I am trying to retrieve posts that are shared by the users to whom i am Subscribed to.

What exactly i did in my UsersController is that i first retrieved the list of all of my friends

 $lof=$this->User->Friendship->find('all', array('conditions'=>array('Friendship.user_from'=>$this->Auth->user('id')), 'contain'=>array('Friendship.user_to')));

Now i am trying to show all the posts shared by my friends

$allnotes= $this->User->Note->find('all', array('conditions'=>array('Note.user_id'=>array($lof)), 'order' => array('Note.created DESC')));

Which gives me an error

Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Array' in 'where clause'

SQL Query: SELECT `Note`.`id`, `Note`.`user_id`, `Note`.`notes`, `Note`.`created`,     `User`.`id`, `User`.`name`, `User`.`email`, `User`.`username`, `User`.`password`, `User`.`gender`, `User`.`dob`, `User`.`image`, `User`.`tmp_name`, `User`.`search` FROM `fyp`.`notes` AS `Note` LEFT JOIN `fyp`.`users` AS `User` ON (`Note`.`user_id` = `User`.`id`) WHERE `Note`.`user_id` = (Array) ORDER BY `Note`.`created` DESC

I know i am trying to add an array but when i tried the same find query like this, it worked.

$allnotes= $this->User->Note->find('all', array('conditions'=>array('Note.user_id'=>array(114,115)), 'order' => array('Note.created DESC')));

What exactly is the solution to get only the values of user_to from Friendship table and assign it equals to Note.user_id in my query.

  • 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-13T20:20:18+00:00Added an answer on June 13, 2026 at 8:20 pm

    The problem is that your $lof variable doesn’t contain an array of id’s. It will contain the full array of data from the Friendship model. If you view the value of the $lof variable you should see what I mean. You can do this using the debug() function.

    To do what you want to do you’ll have to use the ‘list’ find method and use the Friendship.user_to field. Like this:

    $lof = $this->User->Friendship->find('list', array(
        'fields' => array('Friendship.id', 'Friendship.user_to'),
        'conditions' => array(
            'Friendship.user_from' => $this->Auth->user('id')
    ));
    

    And then to find all the notes you can now use

    $allnotes = $this->User->Note->find('all', array(
        'conditions' => array(
             'Note.user_id' => $lof
         ),
         'order' => array('Note.created DESC')
    ));
    

    You can read more about the different find methods (I’ve linked to the list one) in CakePHP’s cookbook

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

Sidebar

Related Questions

I have three models: Post , Comment , User and Vote . I'm using
I have three models that I'm trying to setup: Location/Venues, Categories, and Neighborhoods. A
I have three models: User Image Group . User belongs to an image; Group
I have three models: class User include Mongoid::Document field :name, :type => String has_many
I have three models that are coming together to create one view model and
I have three models: class Book < ActiveRecord::Base has_many :collections has_many :users, :through =>
I have three models that look something like this: class Bucket < ActiveRecord::Base has_many
I have the following models associated with has_many through with conditions. (Note that Membership
I have three models ( User , Tag , Product ) and they interact
I have three tables, 1-Users, 2-Softwares, 3-UserSoftwares. if suppose, Users table having 6 user

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.