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 8642251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:43:44+00:00 2026-06-12T11:43:44+00:00

Here’s the documentation I’ve read and here’s what I’m trying. First I set up

  • 0

Here’s the documentation I’ve read and here’s what I’m trying. First I set up my Model associations:

<?php
class Proveedor extends AppModel {
    public $hasMany = 'Libro';
    public $displayField = 'Nombre';
}

<?php
class Libro extends AppModel {
    public $belongsTo = 'Proveedor';
}

Next, I created my controller and my action function:

public function filter($proveedorName = null) {

    // proveedorName is a string: wrox, apress, oreilly, etc.
    // I need to find all libros that have their 'Proveedor' as $proveedorName.

    $this->set('libros', $this->Libro->find('all', 
    array('conditions' => array('Libros.Proveedor.Name' => $proveedorName))));

    $this->set('proveedores', $this->Libro->Proveedor->find('list'));
}

This is the error message that’s popping up:

Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Libros.Proveedor.Name' in 'where clause'

My use case is quite simple, from a dropdown list select the proveedor and have the website return a collection of books (libros) that come from that supplier (proveedor).

It’s as if you visit: www.google.com/cars/filter/nissan – you want to see all Nissan cars.

Same principal here: www.google.com/libros/filter/apress – I want to fetch all books (libros) from proveedor (supplier) Apress.

For illustrative purposes, in C# using Entity Framework and Linq I can go:

var books = db.Libros.Where(x => x.Proveedor.Name == "Apress");

Can I do something similar with CakePHP?

  • 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-12T11:43:45+00:00Added an answer on June 12, 2026 at 11:43 am

    This is wrong:

    array('conditions' => array('Libros.Proveedor.Name' => $proveedorName))));
    

    Should be:

    array('conditions' => array('Proveedor.Name' => $proveedorName))));
    

    And you database fields should be lower cased (name) and underscored, not upper cased (Name) or anything else. Follow the conventions, it will make things a lot more easy.

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

Sidebar

Related Questions

Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
Here is my class: public class A{ private void doIt(int[] X, int[] Y){ //change
Here is what I am trying to achieve in PHP: I have this string:
Here is my code so far: public class PostfixCalculator { private Stack<Float> stack; private
Here is the code in a function I'm trying to revise. This example works
Here is what I am currently doing. PHP echo's out the recent post in
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here is the css: #content ul { font-size: 12px; } I am trying this:
here is my php code $titikPetaInti = array(); while($row = mysql_fetch_assoc($hasil2)) { $titikPetaInti[] =
Here is the problem that I am trying to solve. I have two folders

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.