Welcome Guest, Not a member yet? Register   Sign In
Nested Query Question (NEWBIE)
#5

[eluser]JesseR[/eluser]
HERE IS MY CONTROLLER:
Code:
<?php
class Catalog extends Controller {

    function Catalog()
    {
        parent::Controller();
        
/*        $this->load->scaffolding('entries');*/
        $this->load->helper('url');
        $this->load->helper('form');
    }
    function index()
    {
    
        $data['query'] = $this->db->get('entries');
        
    
    }
    

    function products()
    {    
        
        $this->db->where('CATEGORY','BECAS'/*$this->uri->segment(3)*/);
        $this->db->like('DESCRIPT', '1 1/2"');
        $data['query_item'] = $this->db->get('ITEMS');
    
        foreach($data['query_item']->result() as $row):

            $items['itemno'] = $row->ITEMNO;
            $items['descript'] = $row->DESCRIPT;
            echo "test";            
            
        /* Get Standard Item Selling Price */
            $this->db->select('SELLPRIC');
            $this->db->where('ITEMNO',$row->ITEMNO);
            $this->db->where('MEAS_TYPE',1);    
                
            $data['query_price'] = $this->db->get('ITEM_MEASURE');                        
            foreach($data['query_price']->result() as $row2):                
            $items['descript'] = $row2->SELLPRIC;

            endforeach;    
        $itemsarray[] = $items;
        
        $data = $itemsarray;
        endforeach;            
        
        
        
        $this->load->view('product_view', $data);
    
    }
}

?>
HERE IS MY VIEW:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Product Page>&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;


<ol>
&lt;?php foreach($data->result() as $row): ?&gt;
<h3>&lt;?=$row->DESCRIPT?&gt;</h3>
<p>&lt;?=$row->WEBDESC?&gt;</p>
<p>&lt;?=$row->SELLPRIC?&gt;</p>

<p>&lt;?=anchor('blog/comments/'. $row->ITEMNO, 'Comments');?&gt;</p>
<hr />
&lt;?php endforeach; ?&gt;
</ol>
&lt;/body&gt;
&lt;/html&gt;



[quote author="jedd" date="1263446790"]
Am I right in assuming that item_eq.itemno = items.itemid - as in a foreign key (or a pretend one, at least).

Why can't you just do a JOIN here? If I'm wrapping my head around your problem properly (and I may well be missing something here - been a big day) it would probably also be easier for the view generation too. Is something like this thread - [/quote]

You are correct ITEM_EQ.ITEMNO = ITEMS.ITEMID. Any record in the ITEM_EQ table will always have a matching record in the ITEMS table. However there are various fields in each table such as CUSTMEMO1, etc... I need to retrieve. If the field CUSTMEMO1 is blank in the ITEM_EQ table I would have to display the field from ITEMS table.

I also need to retrieve the pricing information. If the field ITEM_EQ.SELLPRIC is true I need to use the items original sell price retrieved from a different table with different where arguments but if it is false i would display the price as the value in ITEM_EQ.SELLINGPRICE.

This is just a few examples I hope will make it more clear of my objectives here.
Once again I appreciate your help and look forward to your response.

[quote author="jedd" date="1263446790"]
Yeah - this could be a tad challenging. Is it feasible to apply this logic post-query?[/quote]

What do you mean post-query? Isn't that what I am referring to when I say I want to modify the returned query array results. Maybe I misunderstand the question. Please clarify.


Messages In This Thread
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 03:49 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 04:38 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 04:55 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 05:26 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 11:05 PM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 03:35 AM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 07:12 AM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 08:42 AM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 12:08 PM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 03:08 PM
Nested Query Question (NEWBIE) - by El Forum - 01-15-2010, 03:15 AM
Nested Query Question (NEWBIE) - by El Forum - 01-15-2010, 07:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB