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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:33:14+00:00 2026-05-30T14:33:14+00:00

Look at this code: $sql = $this->getAdapter()->select() ->from(array(‘mab’ => ‘module_adv_banner’)) ->joinLeft(array(‘mafb’ => ‘module_adv_filebanner’),’mab.id =

  • 0

Look at this code:

$sql = $this->getAdapter()->select()
        ->from(array('mab' => 'module_adv_banner'))
        ->joinLeft(array('mafb' => 'module_adv_filebanner'),'mab.id = mafb.id_banner',array('source','type'))
        ->joinLeft(array('macb' => 'module_adv_contentbanner'),'mab.id = macb.id_banner',array('content','type'))
        ->where('mab.id = ?', $this->_id)
        ->order('position asc');

In this query I use 3 tables. First with 'mab' alias – is the main banners table. Two another tables are 'mafb' and 'macb' are specific tables for different banner types. In case the banner is image or swf, it is stored in ‘mafb’ table, in case of banner-informer, I use another table – 'macb'

In this query I select all required elements of banner.
Only one of two specific tables have row with id_banner = mab.id = $this->_id, and each of this tables have field ‘type’. If it finds this row in first table, value of ‘type’ is null, because it is overwritten by second table ‘type’ value. How can I solve that problem?

Best Regards, Ahmed.

p.s.
sorry if my explanation is difficult, I do not have good english knowledge.

  • 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-30T14:33:15+00:00Added an answer on May 30, 2026 at 2:33 pm

    Not going into the details of why you keep 2 tables for one thing (banners)…
    try prepending the tablename to the fields being selected:

      $sql = $this->getAdapter()->select()
            ->from(array('mab' => 'module_adv_banner'))
            ->joinLeft(array('mafb' => 'module_adv_filebanner'),'mab.id = mafb.id_banner',array('mafb.source','mafb.type'))
            ->joinLeft(array('macb' => 'module_adv_contentbanner'),'mab.id = macb.id_banner',array('macb.content','macb.type'))
            ->where('mab.id = ?', $this->_id)
            ->order('position asc');
    

    That will give you 4 fields instead of 2 which you can use in PHP and sort out the thing you need. Although it’s a bit strange, that the adapter didn’t namespace colliding field names.

    BTW, it is sometimes more convenient to pass array() as the 3rd argument to join() and use columns() to define the fields you actually want to pull out.

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

Sidebar

Related Questions

I want to statically allocate the array. Look at the following code, this code
look at this TSQL code: SELECT A, B, C, (MAX(A) - MAX(B))*C AS 'myCalculatedColumn',
please take a look of this query: SELECT DATE(datetime), COUNT(1) as numVisits FROM .table_stats.
look at this code, <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <script> function change() {
Take a look at this code: public class Test { public static void main(String...
take a look at this code: $(document).ready(function() { document.getElementById(sliderId).onmousedown = sliderMouseDown; }); function sliderMouseDown()
Let's look at this code: IList<IHouseAnnouncement> list = new List<IHouseAnnouncement>(); var table = adapter.GetData();
Please take a look at this code: template<class T> class A { class base
There is some problem, i can't understand anyway. look at this code please <script
take a look at this example code: public class Comment { private Comment() {

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.