Пример #1
0
 function checkForDuplicates($prefix)
 {
     require_once 'include/formbase.php';
     $focus = BeanFactory::getBean('Quotes');
     if (!checkRequired($prefix, array_keys($focus->required_fields))) {
         return null;
     }
     $query = '';
     $baseQuery = 'select id, name, quote_stage, from quotes where deleted!=1 and (';
     if (isset($_POST[$prefix . 'name']) && !empty($_POST[$prefix . 'name'])) {
         $query = $baseQuery . "  name like '%" . $_POST[$prefix . 'name'] . "%'";
         $query .= getLikeForEachWord('name', $_POST[$prefix . 'name']);
     }
     if (!empty($query)) {
         $rows = array();
         $db = DBManagerFactory::getInstance();
         $result = $db->query($query . ');');
         while ($row = $db->fetchByAssoc($result)) {
             $rows[] = $row;
         }
         if (count($rows) > 0) {
             return $rows;
         }
     }
     return null;
 }
Пример #2
0
 function checkForDuplicates($prefix)
 {
     require_once 'include/formbase.php';
     $focus = new Opportunity();
     $query = '';
     $baseQuery = 'select id, name, sales_stage,amount, date_closed  from opportunities where deleted!=1 and (';
     if (isset($_POST[$prefix . 'name']) && !empty($_POST[$prefix . 'name'])) {
         $query = $baseQuery . "  name like '%" . $_POST[$prefix . 'name'] . "%'";
         $query .= getLikeForEachWord('name', $_POST[$prefix . 'name']);
     }
     if (!empty($query)) {
         $rows = array();
         global $db;
         $result = $db->query($query . ')');
         $i = -1;
         while (($row = $db->fetchByAssoc($result)) != null) {
             $i++;
             $rows[$i] = $row;
         }
         if ($i == -1) {
             return null;
         }
         return $rows;
     }
     return null;
 }
 function checkForDuplicates($prefix)
 {
     require_once 'include/formbase.php';
     require_once 'modules/Opportunities/Opportunity.php';
     $focus = new Opportunity();
     $query = '';
     $baseQuery = 'select id, name, sales_stage,amount, date_closed  from opportunities where deleted!=1 and (';
     if (isset($_POST[$prefix . 'name']) && !empty($_POST[$prefix . 'name'])) {
         $query = $baseQuery . "  name like '%" . $_POST[$prefix . 'name'] . "%'";
         $query .= getLikeForEachWord('name', $_POST[$prefix . 'name']);
     }
     if (!empty($query)) {
         $rows = array();
         $db =& PearDatabase::getInstance();
         $result = $db->query($query . ')');
         if ($db->getRowCount($result) == 0) {
             return null;
         }
         for ($i = 0; $i < $db->getRowCount($result); $i++) {
             $rows[$i] = $db->fetchByAssoc($result, $i);
         }
         return $rows;
     }
     return null;
 }