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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:51:16+00:00 2026-05-28T05:51:16+00:00

my query is returning me only the library_id. I need to show the title

  • 0

my query is returning me only the library_id. I need to show the title in my view. How can I get the title to show.
here is my share model

public $belongsTo = array(
        'Person' => array(
            'className' => 'Person',
            'foreignKey' => 'person_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'Library' => array(
            'className' => 'Library',
            'foreignKey' => 'library_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        )
    );

here is my Library model

class Library extends AppModel {

    //The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * hasMany associations
 *
 * @var array
 */
    public $hasMany = array(
        'Share' => array(
            'className' => 'Share',
            'foreignKey' => 'library_id',
            'dependent' => false,
            'conditions' => '',
            'fields' => 'Title',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        ),
        'Work' => array(
            'className' => 'Work',
            'foreignKey' => 'library_id',
            'dependent' => false,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        )
    );

}

here is my add method in controller

public function add() {
        if ($this->request->is('post')) {
            $this->Share->create();
            if ($this->Share->save($this->request->data)) {
                $this->Session->setFlash(__('The share has been saved'));
                $this->redirect(array('action' => 'index'));
            } else {
                $this->Session->setFlash(__('The share could not be saved. Please, try again.'));
            }
        }
        $people = $this->Share->Person->find('list');
        $libraries = $this->Share->Library->find('list');
        $this->set(compact('people', 'libraries'));
    }

And here is my view

<div class="shares form">
<?php echo $this->Form->create('Share');?>
    <fieldset>
        <legend><?php echo __('Add Share'); ?></legend>
    <?php
        echo $this->Form->input('person_id');
    echo $this->Form->input('library_id');
        echo $this->Form->input('share');

    ?>
    </fieldset>
<?php echo $this->Form->end(__('Submit'));?>
</div>
  • 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-05-28T05:51:17+00:00Added an answer on May 28, 2026 at 5:51 am

    Never mind the question above all I need to do is

    $libraries = $this->Share->Library->find(‘list’, array(‘fields’=>’Library.Title’));

    in LibrariesController

    thanks

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

Sidebar

Related Questions

My sql query is only returning the children of the parent I need it
My LINQ Query is only returning the first result (Class). Here is the code
For some reason this query is only returning the 10 most recently published results,
There are 3 deposits in my XML file, but the query is only returning
I have a query returning large XML, its size can reach 1GB in extreme
Hi can anyone please tell me why the following code is only returning the
I am using Linq-To-Entities to do a query which is returning only 947 rows
the following mysql query is only returning a single row when it should be
This query is returning values less than 1000. It should only be returning values
I have a query returning 24 records for users with code A and 54

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.