Update function

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
8707
Forum Newbie
Posts: 11
Joined: Thu Jan 07, 2010 7:41 pm

Update function

Post by 8707 »

Code: Select all

function updateHelpDeskSC($focusId, $entityIds) {
        
        if(!is_array($entityIds)) $entityIds = array($entityIds);
        $selectTicketsQuery = "SELECT ticketid FROM vtiger_troubletickets WHERE (servicecontractsid IS NULL OR servicecontractsid = 0) AND ticketid IN (" . generateQuestionMarks($entityIds) .")";
        $selectTicketsResult = $this->db->pquery($selectTicketsQuery, array($entityIds));
        $noOfTickets = $this->db->num_rows($selectTicketsResult);
        for($i=0; $i < $noOfTickets; ++$i) {
            $ticketId = $this->db->query_result($selectTicketsResult,$i,'ticketid');
            $updateQuery = "UPDATE vtiger_troubletickets SET servicecontractsid=vtiger_servicecontracts.servicecontractsid" .
                        " WHERE vtiger_servicecontracts.servicecontractsid = ? AND vtiger_troubletickets.ticketid = ?";         
            $updateResult = $this->db->pquery($updateQuery, array($focusId, $ticketId));
        }
        
    }
Above function is use to update the servicecontractsid of ticket with servicecontractsid of ServiceContracts if the id is empty. But it just cannot execute successfully! So hope someone can help me to fix it!!
TQ
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Update function

Post by andyhoneycutt »

Would you please post the mysql and/or php error(s) you are receiving? This would go a long way to troubleshooting the problem. If needed, check your apache and mysql error logs.
Post Reply