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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:42:13+00:00 2026-05-13T20:42:13+00:00

Apologies for all this code, anyhow Im re-working a query into the Zend query

  • 0

Apologies for all this code, anyhow Im re-working a query into the Zend query way of working, this is what I have so far:

$db = Zend_Registry::get ( "db" );      
    $stmt = $db->query('
    SELECT recipe_pictures.picture_id, recipe_pictures.picture_filename, course.course_name, cuisines.name, recipes.id, recipes.Title, recipes.Method, recipes.author, recipes.SmallDesc, recipes.user_id, recipes.cuisine, recipes.course, recipes.Created_at, recipes.vegetarian, recipes.Acknowledgements, recipes.Time, recipes.Amount, recipes.view_count, recipes.recent_ips, guardian_writers.G_item, guardian_writers.G_type
    FROM recipes
    LEFT JOIN course ON recipes.course = course.course_id
    LEFT JOIN recipe_pictures ON recipes.id = recipe_pictures.recipe_id
    LEFT JOIN cuisines ON recipes.cuisine = cuisines.id
    LEFT JOIN guardian_writers ON recipes.author = guardian_writers.G_author
    WHERE recipes.id = ?', $id);
    $stmt->setFetchMode(Zend_Db::FETCH_ASSOC);
    $recipes = $stmt->fetchAll();

    return $recipes;

That one above works, trying to get the Zend version properly, my effort is below.

    $db = Zend_Registry::get ( "db" );      
    $select = $db->select()
                 ->from(array('r' => 'recipes'))
                 ->join(array('c' => 'course'),
                        'r.course = c.course_id')
                 ->join(array('rp' => 'recipe_pictures'),
                        'r.id = rp.recipe_id')
                 ->join(array('cui' => 'cuisines'),
                        'r.cuisine = cui.id')
                 ->join(array('gw' => 'guardian_writers'),
                        'r.author = gw.G_author')
                 ->where(' id = ? ', $id);

    $recipes = $db->fetchRow($select);

    return $recipes;

If anyone can spot an error Id be very grateful, thanks

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

    Use joinLeft instead of join to produce left joins.

    To fetch specific columns from a table, rather than all (*) use this:

    ->from(array('r' => 'recipes'), array('id', 'title', 'method'))
    

    or

    ->joinLeft(array('rp' => 'recipe_pictures'),
                        'r.id = rp.recipe_id',
                        array('picture_id', 'picture_filename')
                        )
    

    To fetch no columns from a table, pass an empty array as the third parameter.

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

Sidebar

Related Questions

First of all, apologies if this too naive (I am a beginner). I have
Apologies for not posting any code for this but all my efforts seem to
All, Apologies in advance - this question might be too open-ended for SO. Anyway...
First of all, apologies for the subjective sounding title. This is intended as a
First of all, apologize because I have seen some posts about this, but I
In all the Java source code examples I have looked at the listeners have
I am completely new to all of this coding.. so I apologies for my
I have been working on getting a python CGI script to work all day,
First of all my apologies to those of you who would have followed my
Apologies in advance for the length of this question! I have a data structure

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.