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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:38:51+00:00 2026-06-03T23:38:51+00:00

So, i’ve come up with this query wich works perfectly fine when executed. However,

  • 0

So, i’ve come up with this query wich works perfectly fine when executed. However, since I want to use the pagination from Zend, the query has to be through an adapter.

This is the query that has to be converted: (i’ve cut the query so only the important part is here. I am aware of the fact that you can’t run this query LOL)

//snip
WHERE
    city IN (
        SELECT 
            Plaatsnaam
        FROM
            plaatsnamen
        WHERE
            Latitude 
                BETWEEN 
                    ?
                AND 
                    ?
        AND
            Longitude
                BETWEEN
                    ?
                AND
                    ?       
    )
//snip

Works perfectly fine! However.. As you can see, i’m using an “advanced” WHERE IN case. Somehow, i can’t get this converted and i’m stuck.

This is what it has to be converted to:

$db = Zend_Db_Table::getDefaultAdapter();                
$select = $db->select('gethousecity.id, city')
                                ->from('gethousecity')
                                    ->join('houses_props', 'houses_props.id = gethousecity.id')
                                ->where('city IN ()') // HOW TO CONVERT THE UPPER QUERY TO FIT IT HERE?
                                ->where('is_online = 1')
                                ->where('houses_props.prop_name = ?', 'something')
                                ->where('houses_props.prop_value BETWEEN ? AND ?', array(1,2));

I haven’t found any documentation at all on how to convert the query into some format that fits here. Does anyone have any idea? Mostly because I need to insert some values and ZF is rewriting some weird shit there.

I’m kinda stuck now, any help would be awesome!

  • 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-03T23:38:53+00:00Added an answer on June 3, 2026 at 11:38 pm

    Subqueries work just fine.

    $select1->cols('id')->where('date > NOW()');
    $select2->where('id IN (?)', $select1);
    

    If the problem is the complex where, than you can use named parameters.

    $select1 = $db->select();
    $select2 = $db->select();
    $select1->from('plaatsnamen', array('Plaatsnaam'))
            ->where('Latitude BETWEEN :latmin AND :latmax')
            ->where('Longitude BETWEEN :longmin AND :longmax');
    $select2->from('gethousecity')
            ->join('houses_props', 'houses_props.id = gethousecity.id')
            ->where('city IN ?', $select1) // HOW TO CONVERT THE UPPER QUERY TO FIT IT HERE?
            ->where('is_online = 1')
            ->where('houses_props.prop_name = ?', 'something')
            ->where('houses_props.prop_value BETWEEN :propsmin AND :propsmax');
    die($select2);
    

    Returns:

    SELECT `gethousecity`.*, `houses_props`.*
    FROM `gethousecity`
    INNER JOIN `houses_props` ON houses_props.id = gethousecity.id
    WHERE 
        (city IN (
            SELECT `plaatsnamen`.`Plaatsnaam`
            FROM `plaatsnamen`
            WHERE 
            (Latitude BETWEEN :latmin AND :latmax) AND
            (Longitude BETWEEN :longmin AND :longmax)
        )) AND
        (is_online = 1) AND
        (houses_props.prop_name = 'something') AND
        (houses_props.prop_value BETWEEN :propsmin AND :propsmax)
    

    Which should work with named parameters, as seen in manual

    $bind = array(
        ':latmin' => 10,
        ':latmax' => 3,
        '...' => '...',
    );
    $db->fetchAll($select2, $bind);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.