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 what I am trying to achieve in PHP: I have this string:
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 my button element: <button type=submit class=btn-submit><span><strong>Let Me In, please!</strong></span></button> and here's the CSS:
Here's the code require_once 'functions.php'; require_once 'cfg.php'; $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $db);
Here's the code I have. It works. The only problem is that the first
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Here is my code: <?php $variable1 = 00001; $variable2 = (sprintf('%04d', $variable1 + 1));
I'm trying to create an if statement in PHP that prevents a single post

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.