ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

I need to filter listings by getting additional data from an MSSQL database...

August 18, 2011 9:16pm

Subscribe [2]
  • #1 / Aug 18, 2011 9:16pm

    jonnyquist

    75 posts

    I have a loop (below), which pulls companies that are “Market Making”. Basically, if they have a company_type (P&T Dropdown), then the company is Market Making and displays in the list. But that’s not all that makes a company Market Making. It also depends on a cell in a MSSQL database. If it’s Market Making, then the market_making cell in the MSSQL database has the value “Y”.

    So, here’s the EE entries code:

    <section>
                            <ul class="content_list">
                                {exp:channel:entries channel='companies' search:company_type='not none' search:company_rating='buy|high_yield-buy|neutral' dynamic='no' orderby='company_name' sort='asc|desc' paginate='bottom' limit='25'}
                                    <li class="{switch='odd|even'}">
                                        <div>
                                            <span class="company_name"><a href="http://{title_permalink=research/coverage_list}/">{company_name}</a></span>
                                            <span class="company_symbol">{company_symbol}</span>
                                            <span class="company_rating 
                                                {if company_rating == &#039;buy&#039; OR company_rating == &#039;high_yield-buy&#039;}
                                                    buy
                                                {if:elseif company_rating == &#039;neutral&#039; OR company_rating == &#039;high_yield-neutral&#039;}
                                                    neutral
                                                {if:elseif company_rating == &#039;sell&#039; OR company_rating == &#039;high_yield-sell&#039;}
                                                    sell
                                                {if:else}
                                                    none
                                                {/if}
                                            ">{company_rating}</span>
                                            <span class="company_type">
                                                {if company_type == 'amex'}
                                                    AMEX
                                                {if:elseif company_type == 'bulletin_board'}
                                                    Bulletin Board
                                                {if:elseif company_type == 'nasdaq_capital_market'}
                                                    NASDAQ Capital Market
                                                {if:elseif company_type == 'nasdaq_global_market'}
                                                    NASDAQ Global Market
                                                {if:elseif company_type == 'nasdaq_national_market'}
                                                    NASDAQ National Market
                                                {if:elseif company_type == 'non-nasdaq_over-the-counter'}
                                                    Non-NASDAQ Over-the-Counter
                                                {if:elseif company_type == 'nsc'}
                                                    NSC
                                                {if:elseif company_type == 'nyse'}
                                                    NYSE
                                                {if:elseif company_type == 'otcqx'}
                                                    OTCQX
                                                {if:elseif company_type == 'pink_sheets'}
                                                     Pink Sheets
                                                {if:elseif company_type == 'none'}
                                                    None                
                                                {if:else}
                                                    Other
                                                {/if}
                                            </span>
                                        </div>
                                    </li>
                                
                                    {paginate}
                                        <div class="paginate">
                                            Page {current_page} of {total_pages} page{if total_pages > '1'}s{/if} | {pagination_links}
                                        </div>
                                    {/paginate}
                                {/exp:channel:entries}
                            </ul>    
                        </section>


    I have someone coming over tonight that knows a lot more about databases than I do, but I basically need to do this, which I wrote in some kind of phonetic language I made up.

    {exp:channel:entries channel='companies' search:company_type='not none' search:company_rating='buy|high_yield-buy|neutral' dynamic='no' orderby='company_name' sort='asc|desc' paginate='bottom' limit='25'}
        {if MSSQL DATABASE (company) COLUMN (market_making) has value 'Y'}
            ...show the company

    This possible? I also use the {switch} tag and if I use an {if} statement, it’s mess that up. Hm.

  • #2 / Aug 18, 2011 11:57pm

    the3mus1can

    426 posts

    Since you are on EE2 and CI has a database driver for MSSQL this should be possible. 

    You will either need to create a plugin or use PHP in the template to achieve it. 

    You will need to setup a secondary database connection. This may be of assistance http://ellislab.com/forums/viewthread/195522/#920638 and this too http://ellislab.com/codeigniter/user-guide/database/configuration.html

  • #3 / Aug 19, 2011 1:50am

    jonnyquist

    75 posts

    Okay, thank you. Since this is beyond me, I’ll forward those links to Ben.

    Much appreciated! Any further insight is appreciated.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases