Results 1 to 5 of 5

Thread: Run multiple Queries in view.edit.php

  1. #1
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Run multiple Queries in view.edit.php

    Hi,

    I have a custom modules and I have created a view.edit.php yo inherite the team_id of the record it was created under.

    The custom mondule can only be created under contacts so this teh what I want to do.
    PHP Code:
    <?php
    require_once('include/MVC/View/views/view.edit.php');
    class 
    fdc_dependentsViewEdit extends ViewEdit
    {
        function 
    fdc_dependentsViewEdit()
        {
            
    parent::SugarView();
        }
        function 
    display(){

        
    //$this->ev->process();

        
    $this->ev->process();

        if (empty(
    $this->ev->focus->id))
        {
            if (!empty(
    $_REQUEST['return_id']))
            {
                
    $query="SELECT team_id FROM contacts WHERE id ='".$_REQUEST['return_id']."'";
                
    $res=$this->bean->db->query($query);
                
    $row=$this->bean->db->fetchByAssoc($res);
                if (!empty(
    $row))
                {
                    
    $this->ev->fieldDefs['team_id']['value'] = $row['team_id'];
                }
            }

    }

    //echo $this->ev->display();
    echo $this->ev->display();

    }

    }
    The $_REQUEST[return_id] returns the ID of the Custom module and to get the team_id from the contact I need to run the following two queries.

    PHP Code:
    $query1 "SELECT contacts_idb FROM fdc_dependents_contacts WHERE fdc_dependents_ida ='".$_REQUEST['return_id']."'";
    $query2 "SELECT team_id FROM contacts WHERE id = RESULT OF $query1"
    I can then past the result of $query2 tothe team_id of teh custom module.

    How can I do this

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Run multiple Queries in view.edit.php

    You can write a single query with a join between both tables.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  3. #3
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: Run multiple Queries in view.edit.php

    Hi andopes,

    Can you give an example of this - I'm not an expert in mysql yet, only just getting used to simple queries...

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  4. #4
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: Run multiple Queries in view.edit.php

    My old statement works just fine - this is now ok...
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  5. #5
    cmacholz is offline Senior Member
    Join Date
    Sep 2009
    Location
    Missoula, MT
    Posts
    82

    Default Re: Run multiple Queries in view.edit.php

    Where did you create your view.edit.php file?

    I'm trying to do the same thing but I'm confused on which view.edit.php file to change/edit/create.

    Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 2011-01-20, 04:43 AM
  2. Replies: 0
    Last Post: 2009-04-29, 04:42 PM
  3. List View Queries
    By singboy in forum Developer Help
    Replies: 4
    Last Post: 2009-02-11, 12:45 AM
  4. Replies: 5
    Last Post: 2007-05-21, 12:59 PM
  5. Replies: 1
    Last Post: 2007-03-02, 06:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •