public function &getFromObject($alias = false) { static $arrFromObject = array(); static $objFromObject = null; if ($alias === false) { if (is_null($objFromObject)) { $objFromObject = new ClsAuieoSQLFrom(); $objFromObject->setTable($this->module_table); $objFromObject->setDatabase(DATABASE_NAME); } return $objFromObject; } else { if (!isset($arrFromObject[$alias])) { $arrFromObject[$alias] = new ClsAuieoSQLFrom($alias); $objFromObject->setTable($this->module_table); $objFromObject->setDatabase(DATABASE_NAME); } return $arrFromObject[$alias]; } }
public function &getNewDisconnectedFrom() { $from = new ClsAuieoSQLFrom($alias); $from->setTable($table); return $from; }
public function buildFilter(ClsAuieoSQL &$objSQL) { $objFromCandidate=$objSQL->getFromObjectByTableName($this->table); $arrWhere=array(); $objRequest=ClsNaanalRequest::getInstance(); $arrFieldFilter=$objRequest->getData("fldfilter"); if($arrFieldFilter) { $data=$objRequest->getData("data"); $condition=$objRequest->getData("condition"); $boolean=$objRequest->getData("boolean"); $group=$objRequest->getData("boolean"); foreach($arrFieldFilter as $ind=>$fldFilter) { if(empty($data[$ind])) continue; $arrWhere[]=array("field"=>$fldFilter,"data"=>$data[$ind],"condition"=>$condition[$ind],"boolean"=>$boolean[$ind],"group"=>$group[$ind]==1?true:false); } } $where=""; if($arrWhere) foreach($arrWhere as $ind=>$whr) { if(is_numeric($whr["field"])) { $sql="select * from extra_field_settings where extra_field_settings_id={$whr["field"]}"; $db = DatabaseConnection::getInstance(); $arrRow=$db->getAllAssoc($sql); $field_name=$arrRow[0]["field_name"]; $ctable="STABLE{$ind}"; $cfield="`STABLE{$ind}`.`{$field_name}`"; $cquery="select {$this->table}.{$this->table}_id as `parent_table_id{$ind}`,`ext{$ind}`.`value` AS `{$field_name}` from {$this->table} left join `extra_field` AS `ext{$ind}` ON {$this->table}.{$this->table}_id = ext{$ind}.data_item_id AND ext{$ind}.field_name='{$field_name}'"; $cfrom=$objSQL->addQuery($cquery,$ctable); $cjoin=$cfrom->addJoinField("parent_table_id{$ind}"); $ccandidate=new ClsAuieoSQLFrom(); $ccandidate->setTable("candidate"); $ccjoin=$ccandidate->addJoinField("candidate_id");//trace($cjoin); $cfrom->setJoinWith($ccandidate,$ccjoin, $cjoin); $objSQL->addSelect($cfrom, $field_name); $objWhere=$objSQL->addWhere($cfrom, $field_name, $whr["data"]); } else { $objWhere=$objSQL->addWhere($objFromCandidate, $whr["field"], $whr["data"]); $boolean=$arrWhere[$ind]["boolean"]; $objWhere->setBoolean($boolean); } if($whr["group"]==1) { $objWhere->setGroup(); } if(empty($where)) { if($whr["condition"]=="equals") { } else { $objWhere->setCondition("like"); } } else { if($whr["condition"]=="equals") { } else { $objWhere->setCondition("like"); } } } }