This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

ListCurrentMailboxes($mid) in controller.ext.php
#1
ListCurrentMailboxes($mid) in controller.ext.php
file: /etc/sentora/panel/modules/mailboxes/code/controller.ext.php

I don't see why there are 2 sql querys executed here:

PHP Code:
static function ListCurrentMailboxes($mid)
 
   {
 
       global $zdbh;
 
       $sql "SELECT * FROM x_mailboxes WHERE mb_id_pk=:mid AND mb_deleted_ts IS NULL ORDER BY mb_address_vc ASC";
 
       //$numrows = $zdbh->query($sql);


---> QUERY1 start here
        
        $numrows 
$zdbh->prepare($sql);
 
       $numrows->bindParam(':mid'$mid);
 
       $numrows->execute();

---> 
IF it returns anything then execute again to parse
        if 
($numrows->fetchColumn() <> 0) {
 
           $sql $zdbh->prepare($sql);
 
           $sql->bindParam(':mid'$mid);
            
$res = array();
 
           $sql->execute();
 
           
            while 
($rowmailboxes $sql->fetch()) {
 
               if ($rowmailboxes['mb_enabled_in'] == 1) {
 
                   $ischeck "CHECKED";
 
               } else {
 
                   $ischeck NULL;
 
               }
 
               $res[] = array('address' => $rowmailboxes['mb_address_vc'],
 
                   'created' => date(ctrl_options::GetSystemOption('sentora_df'), $rowmailboxes['mb_created_ts']),
 
                   'ischeck' => $ischeck,
 
                   'id' => $rowmailboxes['mb_id_pk']);
 
           }
 
           return $res;
 
       } else {
 
           return false;
 
       }
 
   



couldn't it be solved like this:

PHP Code:
static function ListCurrentMailboxes($mid)
 
   {
 
       global $zdbh;
 
       $sql "SELECT * FROM x_mailboxes WHERE mb_id_pk=:mid AND mb_deleted_ts IS NULL ORDER BY mb_address_vc ASC";
 
       
        $numrows 
$zdbh->prepare($sql);
 
       $numrows->bindParam(':mid'$mid);
 
       $numrows->execute();

 
       if ($numrows->fetchColumn() <> 0) {
 
           $res = array();
 
           
            while 
($rowmailboxes $numrows->fetch()) {
 
               if ($rowmailboxes['mb_enabled_in'] == 1) {
 
                   $ischeck "CHECKED";
 
               } else {
 
                   $ischeck NULL;
 
               }
 
               $res[] = array('address' => $rowmailboxes['mb_address_vc'],
 
                   'created' => date(ctrl_options::GetSystemOption('sentora_df'), $rowmailboxes['mb_created_ts']),
 
                   'ischeck' => $ischeck,
 
                   'id' => $rowmailboxes['mb_id_pk']);
 
           }
 
           return $res;
 
       } else {
 
           return false;
 
       }
 
   
Reply
Thanks given by: Me.B


Messages In This Thread
ListCurrentMailboxes($mid) in controller.ext.php - by Vedran B - 01-12-2016, 08:34 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)