public function getByUser($email)
 {
     $roadScope = new QueryScope("roadrout");
     $roadScope->setFields(array("*"));
     $roadCond = new QueryCondition("roadrout");
     $roadCond->setConditions(array(new QueryConditionMember("driverid", $email, "=")));
     $this->addQueryScope($roadScope);
     $this->addQueryCondition($roadCond);
     return $this->select()->fetchAll(PDO::FETCH_CLASS, 'Entity\\Roadrout');
 }
 public function updateCar(Car $car)
 {
     if ($this->validate($car)) {
         $carScope = new QueryScope("car");
         $carScope->setFields(array("brand", "model", "color", "seats", "fuelrate"));
         $carScope->setValues(array($car->brand, $car->model, $car->color, $car->seats, $car->fuelrate));
         $carCond = new QueryCondition("car");
         $carCond->setConditions(array(new QueryConditionMember("regnumber", $car->regnumber, "=")));
         $this->addQueryScope($carScope);
         $this->addQueryCondition($carCond);
         return $this->update();
     }
     return false;
 }
 public function updateUser(User $user)
 {
     if ($this->validate($user)) {
         $userScope = new QueryScope("user");
         $userScope->setFields(array("username", "surname", "birthday", "gendor", "phone", "userpassword"));
         $userScope->setValues(array($user->username, $user->surname, $user->birthday, $user->gendor, $user->phone, $user->userpassword));
         $userCond = new QueryCondition("user");
         $userCond->setConditions(array(new QueryConditionMember("email", $user->email, "=")));
         $this->addQueryScope($userScope);
         $this->addQueryCondition($userCond);
         return $this->update();
     }
     return false;
 }
 /**
  * Main utility method to aid with data binding.  It is used by the default BindAllRows() databinder but
  * could and should be used by any custom databind methods that would be used for instances of this
  * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. 
  *
  * If a paginator is set on this DataBinder, it will use it.  If not, then no pagination will be used.
  * It will also perform any sorting (if applicable).
  *
  * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself
  * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query		 
  * @return void
  */
 public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null)
 {
     // Setup input parameters to default values if none passed in
     if (!$objCondition) {
         $objCondition = QQ::All();
     }
     $objClauses = $objOptionalClauses ? $objOptionalClauses : array();
     // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = QueryCondition::QueryCount($objCondition, $objClauses);
     }
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be a Query result from QueryCondition, given the clauses above
     $this->DataSource = QueryCondition::QueryArray($objCondition, $objClauses);
 }
Beispiel #5
0
    /**
     * Deletes all associated QueryConditions
     * @return void
     */
    public function DeleteAllQueryConditions()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateQueryCondition on this unsaved QueryNode.');
        }
        // Get the Database Object for this Class
        $objDatabase = QueryNode::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (QueryCondition::LoadArrayByQueryNodeId($this->intId) as $objQueryCondition) {
                $objQueryCondition->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`query_condition`
				WHERE
					`query_node_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
Beispiel #6
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objSearchQuery) {
         $objObject->objSearchQuery = SearchQuery::GetSoapObjectFromObject($objObject->objSearchQuery, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intSearchQueryId = null;
         }
     }
     if ($objObject->objOrQueryCondition) {
         $objObject->objOrQueryCondition = QueryCondition::GetSoapObjectFromObject($objObject->objOrQueryCondition, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intOrQueryConditionId = null;
         }
     }
     if ($objObject->objQueryOperation) {
         $objObject->objQueryOperation = QueryOperation::GetSoapObjectFromObject($objObject->objQueryOperation, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intQueryOperationId = null;
         }
     }
     if ($objObject->objQueryNode) {
         $objObject->objQueryNode = QueryNode::GetSoapObjectFromObject($objObject->objQueryNode, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intQueryNodeId = null;
         }
     }
     return $objObject;
 }
 /**
  * This will save this object's QueryCondition instance,
  * updating only the fields which have had a control created for it.
  */
 public function SaveQueryCondition()
 {
     try {
         // Update any fields for controls that have been created
         if ($this->lstSearchQuery) {
             $this->objQueryCondition->SearchQueryId = $this->lstSearchQuery->SelectedValue;
         }
         if ($this->lstOrQueryCondition) {
             $this->objQueryCondition->OrQueryConditionId = $this->lstOrQueryCondition->SelectedValue;
         }
         if ($this->lstQueryOperation) {
             $this->objQueryCondition->QueryOperationId = $this->lstQueryOperation->SelectedValue;
         }
         if ($this->lstQueryNode) {
             $this->objQueryCondition->QueryNodeId = $this->lstQueryNode->SelectedValue;
         }
         if ($this->txtValue) {
             $this->objQueryCondition->Value = $this->txtValue->Text;
         }
         // Update any UniqueReverseReferences (if any) for controls that have been created for it
         if ($this->lstQueryConditionAsOr) {
             $this->objQueryCondition->QueryConditionAsOr = QueryCondition::Load($this->lstQueryConditionAsOr->SelectedValue);
         }
         // Save the QueryCondition object
         $this->objQueryCondition->Save();
         // Finally, update any ManyToManyReferences (if any)
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
Beispiel #8
0
 public function Save()
 {
     $this->objSearchQuery->DeleteAllQueryConditions();
     foreach ($this->objQueryConditionArray as $intIndex => $objQueryCondition) {
         $lstNode = $this->objForm->GetControl('lstNode' . $intIndex);
         $lstOperation = $this->objForm->GetControl('lstOperation' . $intIndex);
         $pnlValue = $this->objForm->GetControl('pnlValue' . $intIndex);
         $ctlValue = $this->objForm->GetControl('ctlValue' . $intIndex);
         if ($lstNode->SelectedValue) {
             $objQueryCondition = new QueryCondition();
             $objQueryCondition->SearchQuery = $this->objSearchQuery;
             $objQueryCondition->QueryOperationId = $lstOperation->SelectedValue;
             $objQueryCondition->QueryNodeId = $lstNode->SelectedValue;
             if ($ctlValue->Visible) {
                 switch ($this->objNodeArray[$lstNode->SelectedValue]->QueryDataTypeId) {
                     case QueryDataType::DateValue:
                         $objQueryCondition->Value = $ctlValue->DateTime->ToString('YYYY-MM-DD');
                         break;
                     case QueryDataType::IntegerValue:
                     case QueryDataType::StringValue:
                         $objQueryCondition->Value = trim($ctlValue->Text);
                         break;
                     case QueryDataType::BooleanValue:
                         $objQueryCondition->Value = trim($ctlValue->SelectedValue);
                         break;
                     case QueryDataType::TypeValue:
                     case QueryDataType::ObjectValue:
                     case QueryDataType::CustomValue:
                     case QueryDataType::CustomValueOnly:
                         $objQueryCondition->Value = trim($ctlValue->SelectedValue);
                         break;
                     default:
                         throw new Exception('Unhandled QueryDataTypeId');
                 }
             }
             $objQueryCondition->Save();
         }
     }
 }