Пример #1
0
 /**
  * Set the from bean
  *
  * @param SugarBean $bean
  * @param bool $alias
  *
  * @return SugarQuery
  */
 public function from(SugarBean $bean, $options = array())
 {
     $alias = isset($options['alias']) ? $options['alias'] : false;
     if (!empty($alias)) {
         $newAlias = $this->db->getValidDBName($alias, false, 'alias');
         if (strtolower($alias) != $newAlias) {
             throw new SugarQueryException("From alias is more than the max allowed length for an alias");
         }
     }
     $team_security = isset($options['team_security']) ? $options['team_security'] : true;
     $add_deleted = isset($options['add_deleted']) ? $options['add_deleted'] : true;
     $this->from = $bean;
     if (!empty($alias)) {
         $this->from = array($bean, $alias);
     }
     if ($team_security === true) {
         $bean->addVisibilityQuery($this, array('table_alias' => $alias));
     }
     if ($add_deleted === true) {
         $this->where()->equals('deleted', 0);
     }
     $this->rebuildFields();
     return $this;
 }