private static function _setFinalLogicalJunction($pEssentialPrimeImplicants, $pFlattenedLiterals, $pLiteralsToFactoryze, $pLiteralKeys)
 {
     $lLiteralsToFactoryzeByKey = array();
     $lFirstConjunction = new LogicalJunction(LogicalJunction::CONJUNCTION);
     if (!empty($pLiteralsToFactoryze)) {
         foreach ($pLiteralsToFactoryze as $pLiteralIndex) {
             $lFirstConjunction->addLiteral($pFlattenedLiterals[$pLiteralKeys[$pLiteralIndex]]);
             $lLiteralsToFactoryzeByKey[$pLiteralIndex] = null;
         }
     }
     $lDisjunction = new LogicalJunction(LogicalJunction::DISJUNCTION);
     $lFirstConjunction->addLogicalJunction($lDisjunction);
     foreach ($pEssentialPrimeImplicants as $lEssentialPrimeImplicantValues) {
         $lConjunction = new LogicalJunction(LogicalJunction::CONJUNCTION);
         foreach ($lEssentialPrimeImplicantValues as $lIndex => $lValue) {
             // if literal hasn't been factorised
             if (!array_key_exists($lIndex, $lLiteralsToFactoryzeByKey)) {
                 if ($lValue === true) {
                     $lConjunction->addLiteral($pFlattenedLiterals[$pLiteralKeys[$lIndex]]);
                 } else {
                     if ($lValue === false) {
                         $lLiteral = $pFlattenedLiterals[$pLiteralKeys[$lIndex]];
                         $lOppositeLiteral = clone $lLiteral;
                         $lOppositeLiteral->reverseOperator();
                         $lConjunction->addLiteral($lOppositeLiteral);
                     }
                 }
             }
         }
         $lDisjunction->addLogicalJunction($lConjunction);
     }
     return $lFirstConjunction;
 }
Пример #2
0
 private function _loadObjectFromDatabase($pObject, $pSelectColumns, $pWhereColumns, $lLogicalJunctionType)
 {
     $lSuccess = false;
     if (!array_key_exists($this->getValue("database")->getValue("id"), self::$sDbObjectById)) {
         $this->_initDbObject();
     }
     if (!$this->mInitialized) {
         $this->_initColumnsProperties($pObject->getModel());
     }
     $lLinkedLiteral = new LogicalJunction($lLogicalJunctionType);
     foreach ($pWhereColumns as $lColumn => $lValue) {
         $lLinkedLiteral->addLiteral(new Literal($this->getValue("name"), $lColumn, "=", $lValue));
     }
     $lSelectQuery = new SelectQuery($this->getValue("name"));
     $lSelectQuery->setWhereLogicalJunction($lLinkedLiteral);
     foreach ($pSelectColumns as $lColumn) {
         $lSelectQuery->addSelectColumn($lColumn);
     }
     $lResult = self::$sDbObjectById[$this->getValue("database")->getValue("id")]->executeQuery($lSelectQuery);
     $lIsModelArray = $pObject->getModel() instanceof ModelArray;
     if (is_array($lResult) && ($lIsModelArray || count($lResult) == 1)) {
         if (!$lIsModelArray) {
             $lResult = $lResult[0];
         }
         if (empty($pSelectColumns)) {
             $pObject->fromSqlDataBase($lResult, self::getDatabaseConnectionTimeZone());
         } else {
             $pObject->fromSqlDataBaseId($lResult, self::getDatabaseConnectionTimeZone());
         }
         $lSuccess = true;
     }
     return $lSuccess;
 }