Example #1
0
 function Page_Main()
 {
     $qs = new cQueryString();
     if ($qs->Count > 0) {
         $Sql = $qs->getValue("s");
         $Sql = TEAdecrypt($Sql, EW_RANDOM_KEY);
         if ($Sql != "") {
             // Get the filter values (for "IN")
             $Value = ew_AdjustSql($qs->getConvertedValue("f"));
             if ($Value != "") {
                 $arValue = explode(",", $Value);
                 $FldType = $qs->getValue("lft");
                 // Filter field data type
                 if (is_numeric($FldType)) {
                     $FldType = intval($FldType);
                 }
                 $cnt = count($arValue);
                 for ($i = 0; $i < $cnt; $i++) {
                     $arValue[$i] = ew_QuotedValue($arValue[$i], $FldType);
                 }
                 $Sql = str_replace("{filter_value}", implode(",", $arValue), $Sql);
             }
             // get the query value (for "LIKE" or "=")
             $Value = ew_AdjustSql($qs->getConvertedValue("q"));
             if ($Value != "") {
                 $Sql = str_replace("{query_value}", $Value, $Sql);
             }
             $this->GetLookupValues($Sql);
         }
     } else {
         die("Missing querystring.");
     }
 }
Example #2
0
 function Page_Main()
 {
     $GLOBALS["Page"] =& $this;
     $post = ew_StripSlashes($_POST);
     if (count($post) == 0) {
         die("Missing post data.");
     }
     //$sql = $qs->getValue("s");
     $sql = @$post["s"];
     $sql = ew_Decrypt($sql);
     if ($sql == "") {
         die("Missing SQL.");
     }
     if (strpos($sql, "{filter}") > 0) {
         $filters = "";
         for ($i = 0; $i < 5; $i++) {
             // Get the filter values (for "IN")
             $filter = ew_Decrypt(@$post["f" . $i]);
             if ($filter != "") {
                 $value = @$post["v" . $i];
                 if ($value == "") {
                     if ($i > 0) {
                         // Empty parent field
                         //continue; // Allow
                         ew_AddFilter($filters, "1=0");
                     }
                     // Disallow
                     continue;
                 }
                 $arValue = explode(",", $value);
                 $fldtype = intval(@$post["t" . $i]);
                 for ($j = 0, $cnt = count($arValue); $j < $cnt; $j++) {
                     $arValue[$j] = ew_QuotedValue($arValue[$j], ew_FieldDataType($fldtype));
                 }
                 $filter = str_replace("{filter_value}", implode(",", $arValue), $filter);
                 ew_AddFilter($filters, $filter);
             }
         }
         $sql = str_replace("{filter}", $filters != "" ? $filters : "1=1", $sql);
     }
     // Get the query value (for "LIKE" or "=")
     $value = ew_AdjustSql(@$post["q"]);
     if ($value != "") {
         $sql = preg_replace('/LIKE \'(%)?\\{query_value\\}%\'/', ew_Like('\'$1{query_value}%\''), $sql);
         $sql = str_replace("{query_value}", $value, $sql);
     }
     // Replace {query_value_n}
     preg_match_all('/\\{query_value_(\\d+)\\}/', $sql, $out);
     $cnt = count($out[0]);
     for ($i = 0; $i < $cnt; $i++) {
         $j = $out[1][$i];
         $v = ew_AdjustSql(@$post["q" . $j]);
         $sql = str_replace("{query_value_" . $j . "}", $v, $sql);
     }
     $this->GetLookupValues($sql);
 }
Example #3
0
 function Page_Main()
 {
     $post = ew_StripSlashes($_POST);
     if (count($post) == 0) {
         die("Missing post data.");
     }
     //$sql = $qs->getValue("s");
     $sql = $post["s"];
     $sql = TEAdecrypt($sql, EW_RANDOM_KEY);
     if ($sql == "") {
         die("Missing SQL.");
     }
     if (strpos($sql, "{filter}") > 0) {
         $filters = "";
         for ($i = 0; $i < 5; $i++) {
             // Get the filter values (for "IN")
             $filter = TEAdecrypt($post["f" . $i], EW_RANDOM_KEY);
             if ($filter != "") {
                 $value = $post["v" . $i];
                 if ($value == "") {
                     if ($i > 0) {
                         // Empty parent field
                         //continue; // Allow
                         ew_AddFilter($filters, "1=0");
                     }
                     // Disallow
                     continue;
                 }
                 $arValue = explode(",", $value);
                 $fldtype = intval($post["t" . $i]);
                 for ($j = 0, $cnt = count($arValue); $j < $cnt; $j++) {
                     $arValue[$j] = ew_QuotedValue($arValue[$j], ew_FieldDataType($fldtype));
                 }
                 $filter = str_replace("{filter_value}", implode(",", $arValue), $filter);
                 ew_AddFilter($filters, $filter);
             }
         }
         $sql = str_replace("{filter}", $filters != "" ? $filters : "1=1", $sql);
     }
     // Get the query value (for "LIKE" or "=")
     $value = ew_AdjustSql(@$post["q"]);
     if ($value != "") {
         $sql = preg_replace('/LIKE \'(%)?\\{query_value\\}%\'/', ew_Like('\'$1{query_value}%\''), $sql);
         $sql = str_replace("{query_value}", $value, $sql);
     }
     // Check custom function
     $fn = @$post["fn"];
     if ($fn != "" && function_exists($fn)) {
         // Custom function(&$sql)
         $sql = $fn($sql);
     }
     $this->GetLookupValues($sql);
 }
Example #4
0
 function Delete(&$rs, $where = "")
 {
     global $conn;
     // Cascade delete detail table 'gallery_detail'
     if (!isset($GLOBALS["gallery_detail"])) {
         $GLOBALS["gallery_detail"] = new cgallery_detail();
     }
     $rscascade = array();
     $GLOBALS["gallery_detail"]->Delete($rscascade, "`g_id` = " . ew_QuotedValue($rs['g_id'], EW_DATATYPE_NUMBER));
     return $conn->Execute($this->DeleteSQL($rs, $where));
 }
Example #5
0
 function BuildBasicSearchSql(&$Where, &$Fld, $Keyword)
 {
     if ($Keyword == EW_NULL_VALUE) {
         $sWrk = $Fld->FldExpression . " IS NULL";
     } elseif ($Keyword == EW_NOT_NULL_VALUE) {
         $sWrk = $Fld->FldExpression . " IS NOT NULL";
     } else {
         $sFldExpression = $Fld->FldVirtualExpression != $Fld->FldExpression ? $Fld->FldVirtualExpression : $Fld->FldBasicSearchExpression;
         $sWrk = $sFldExpression . ew_Like(ew_QuotedValue("%" . $Keyword . "%", EW_DATATYPE_STRING));
     }
     if ($Where != "") {
         $Where .= " OR ";
     }
     $Where .= $sWrk;
 }
 function DeleteSQL(&$rs)
 {
     $SQL = "DELETE FROM `categories` WHERE ";
     $SQL .= EW_DB_QUOTE_START . 'id' . EW_DB_QUOTE_END . '=' . ew_QuotedValue($rs['id'], $this->id->FldDataType) . ' AND ';
     if (substr($SQL, -5) == " AND ") {
         $SQL = substr($SQL, 0, strlen($SQL) - 5);
     }
     if ($this->CurrentFilter != "") {
         $SQL .= " AND " . $this->CurrentFilter;
     }
     return $SQL;
 }
 function DeleteSQL(&$rs, $where = "")
 {
     $sql = "DELETE FROM " . $this->UpdateTable . " WHERE ";
     if ($rs) {
         $sql .= ew_QuotedName('subject_type_id') . '=' . ew_QuotedValue($rs['subject_type_id'], $this->subject_type_id->FldDataType) . ' AND ';
     }
     if (substr($sql, -5) == " AND ") {
         $sql = substr($sql, 0, -5);
     }
     $filter = $this->CurrentFilter;
     ew_AddFilter($filter, $where);
     if ($filter != "") {
         $sql .= " AND " . $filter;
     }
     return $sql;
 }
 function UpdateSQL(&$rs, $where = "")
 {
     $sql = "UPDATE " . $this->UpdateTable . " SET ";
     foreach ($rs as $name => $value) {
         if (!isset($this->fields[$name])) {
             continue;
         }
         $sql .= $this->fields[$name]->FldExpression . "=";
         $sql .= ew_QuotedValue($value, $this->fields[$name]->FldDataType) . ",";
     }
     while (substr($sql, -1) == ",") {
         $sql = substr($sql, 0, -1);
     }
     $filter = $this->CurrentFilter;
     ew_AddFilter($filter, $where);
     if ($filter != "") {
         $sql .= " WHERE " . $filter;
     }
     return $sql;
 }
 function DeleteSQL(&$rs)
 {
     $SQL = "DELETE FROM Subscriptions Inner Join Customers On Customers.CustomerID = Subscriptions.CustomerID Left Join Orders On Subscriptions.DeliveryDate = Orders.DeliveryDate And Subscriptions.CustomerID = Orders.CustomerID WHERE ";
     $SQL .= EW_DB_QUOTE_START . 'SubscriptionID' . EW_DB_QUOTE_END . '=' . ew_QuotedValue($rs['SubscriptionID'], $this->SubscriptionID->FldDataType) . ' AND ';
     if (substr($SQL, -5) == " AND ") {
         $SQL = substr($SQL, 0, strlen($SQL) - 5);
     }
     if ($this->CurrentFilter != "") {
         $SQL .= " AND " . $this->CurrentFilter;
     }
     return $SQL;
 }
Example #10
0
 function Delete(&$rs, $where = "")
 {
     global $conn;
     // Cascade delete detail table 'seguimiento_tramites'
     if (!isset($GLOBALS["seguimiento_tramites"])) {
         $GLOBALS["seguimiento_tramites"] = new cseguimiento_tramites();
     }
     $rscascade = array();
     $GLOBALS["seguimiento_tramites"]->Delete($rscascade, "`id_tramite` = " . ew_QuotedValue($rs['codigo'], EW_DATATYPE_NUMBER));
     return $conn->Execute($this->DeleteSQL($rs, $where));
 }
 function UpdateSQL(&$rs, $where = "", $curfilter = TRUE)
 {
     $sql = "UPDATE " . $this->UpdateTable . " SET ";
     foreach ($rs as $name => $value) {
         if (!isset($this->fields[$name]) || $this->fields[$name]->FldIsCustom) {
             continue;
         }
         if (EW_ENCRYPTED_PASSWORD && $name == 'admin_pass') {
             $value = EW_CASE_SENSITIVE_PASSWORD ? ew_EncryptPassword($value) : ew_EncryptPassword(strtolower($value));
         }
         $sql .= $this->fields[$name]->FldExpression . "=";
         $sql .= ew_QuotedValue($value, $this->fields[$name]->FldDataType, $this->DBID) . ",";
     }
     while (substr($sql, -1) == ",") {
         $sql = substr($sql, 0, -1);
     }
     $filter = $curfilter ? $this->CurrentFilter : "";
     if (is_array($where)) {
         $where = $this->ArrayToFilter($where);
     }
     ew_AddFilter($filter, $where);
     if ($filter != "") {
         $sql .= " WHERE " . $filter;
     }
     return $sql;
 }
 function Delete(&$rs, $where = "")
 {
     global $conn;
     // Cascade delete detail table 'servicio_medico_prestado'
     if (!isset($GLOBALS["servicio_medico_prestado"])) {
         $GLOBALS["servicio_medico_prestado"] = new cservicio_medico_prestado();
     }
     $rscascade = array();
     $GLOBALS["servicio_medico_prestado"]->Delete($rscascade, "`idservicio_medico` = " . ew_QuotedValue($rs['idservicio_medico'], EW_DATATYPE_NUMBER));
     return $conn->Execute($this->DeleteSQL($rs, $where));
 }
Example #13
0
 function DeleteSQL(&$rs)
 {
     $SQL = "DELETE FROM patient_detail Inner Join patient_main On patient_detail.PatientID = patient_main.PatientID WHERE ";
     $SQL .= EW_DB_QUOTE_START . 'DetailNo' . EW_DB_QUOTE_END . '=' . ew_QuotedValue($rs['DetailNo'], $this->DetailNo->FldDataType) . ' AND ';
     if (substr($SQL, -5) == " AND ") {
         $SQL = substr($SQL, 0, strlen($SQL) - 5);
     }
     if ($this->CurrentFilter != "") {
         $SQL .= " AND " . $this->CurrentFilter;
     }
     return $SQL;
 }
Example #14
0
 function Page_Main()
 {
     global $conn;
     $GLOBALS["Page"] =& $this;
     $post = ew_StripSlashes($_POST);
     if (count($post) == 0) {
         die("Missing post data.");
     }
     //$sql = $qs->getValue("s");
     $sql = @$post["s"];
     $sql = ew_Decrypt($sql);
     if ($sql == "") {
         die("Missing SQL.");
     }
     $dbid = @$post["d"];
     $conn = ew_Connect($dbid);
     // Global Page Loading event (in userfn*.php)
     Page_Loading();
     if (ob_get_length()) {
         // Clear output
         ob_clean();
     }
     if (strpos($sql, "{filter}") > 0) {
         $filters = "";
         $ar = preg_grep('/^f\\d+$/', array_keys($post));
         foreach ($ar as $key) {
             // Get the filter values (for "IN")
             $filter = ew_Decrypt(@$post[$key]);
             if ($filter != "") {
                 $i = preg_replace('/^f/', '', $key);
                 $value = @$post["v" . $i];
                 if ($value == "") {
                     if ($i > 0) {
                         // Empty parent field
                         //continue; // Allow
                         ew_AddFilter($filters, "1=0");
                     }
                     // Disallow
                     continue;
                 }
                 $arValue = explode(",", $value);
                 $fldtype = intval(@$post["t" . $i]);
                 $flddatatype = ew_FieldDataType($fldtype);
                 $bValidData = TRUE;
                 for ($j = 0, $cnt = count($arValue); $j < $cnt; $j++) {
                     if ($flddatatype == EW_DATATYPE_NUMBER && !is_numeric($arValue[$j])) {
                         $bValidData = FALSE;
                         break;
                     } else {
                         $arValue[$j] = ew_QuotedValue($arValue[$j], $flddatatype, $dbid);
                     }
                 }
                 if ($bValidData) {
                     $filter = str_replace("{filter_value}", implode(",", $arValue), $filter);
                 } else {
                     $filter = "1=0";
                 }
                 $fn = @$post["fn" . $i];
                 if ($fn == "" || !function_exists($fn)) {
                     $fn = "ew_AddFilter";
                 }
                 $fn($filters, $filter);
             }
         }
         $sql = str_replace("{filter}", $filters != "" ? $filters : "1=1", $sql);
     }
     // Get the query value (for "LIKE" or "=")
     $value = ew_AdjustSql(@$_GET["q"], $dbid);
     // Get the query value from querystring
     if ($value == "") {
         $value = ew_AdjustSql(@$post["q"], $dbid);
     }
     // Get the value from post
     if ($value != "") {
         $sql = preg_replace('/LIKE \'(%)?\\{query_value\\}%\'/', ew_Like('\'$1{query_value}%\'', $dbid), $sql);
         $sql = str_replace("{query_value}", $value, $sql);
     }
     // Replace {query_value_n}
     preg_match_all('/\\{query_value_(\\d+)\\}/', $sql, $out);
     $cnt = count($out[0]);
     for ($i = 0; $i < $cnt; $i++) {
         $j = $out[1][$i];
         $v = ew_AdjustSql(@$post["q" . $j], $dbid);
         $sql = str_replace("{query_value_" . $j . "}", $v, $sql);
     }
     $this->GetLookupValues($sql, $dbid);
     $result = ob_get_contents();
     // Global Page Unloaded event (in userfn*.php)
     Page_Unloaded();
     if (ob_get_length()) {
         // Clear output
         ob_clean();
     }
     // Close connection
     ew_CloseConn();
     // Output
     echo $result;
 }
 function DeleteSQL(&$rs)
 {
     $SQL = "DELETE FROM `Subscriptions` WHERE ";
     $SQL .= EW_DB_QUOTE_START . 'DeliveryDate' . EW_DB_QUOTE_END . '=' . ew_QuotedValue($rs['DeliveryDate'], $this->DeliveryDate->FldDataType) . ' AND ';
     $SQL .= EW_DB_QUOTE_START . 'CustomerID' . EW_DB_QUOTE_END . '=' . ew_QuotedValue($rs['CustomerID'], $this->CustomerID->FldDataType) . ' AND ';
     if (substr($SQL, -5) == " AND ") {
         $SQL = substr($SQL, 0, strlen($SQL) - 5);
     }
     if ($this->CurrentFilter != "") {
         $SQL .= " AND " . $this->CurrentFilter;
     }
     return $SQL;
 }
 function DeleteSQL(&$rs)
 {
     $SQL = "DELETE FROM `tbl_user_level_permissions` WHERE ";
     $SQL .= ew_QuotedName('userlevelid') . '=' . ew_QuotedValue($rs['userlevelid'], $this->userlevelid->FldDataType) . ' AND ';
     $SQL .= ew_QuotedName('tablename') . '=' . ew_QuotedValue($rs['tablename'], $this->ztablename->FldDataType) . ' AND ';
     if (substr($SQL, -5) == " AND ") {
         $SQL = substr($SQL, 0, strlen($SQL) - 5);
     }
     if ($this->CurrentFilter != "") {
         $SQL .= " AND " . $this->CurrentFilter;
     }
     return $SQL;
 }
Example #17
0
 function UserLevelNameList()
 {
     $list = "";
     foreach ($this->UserLevelID as $UserLevelID) {
         if ($list != "") {
             $list .= ", ";
         }
         $list .= ew_QuotedValue($this->GetUserLevelName($UserLevelID), EW_DATATYPE_STRING);
     }
     return $list;
 }
Example #18
0
 function UserIDList()
 {
     $ar = $this->UserID;
     $len = count($ar);
     for ($i = 0; $i < $len; $i++) {
         $ar[$i] = ew_QuotedValue($ar[$i], EW_DATATYPE_NUMBER);
     }
     return implode(", ", $ar);
 }
Example #19
0
 function DeleteSQL(&$rs)
 {
     $SQL = "DELETE FROM `tbl_rank_stat` WHERE ";
     $SQL .= ew_QuotedName('id_profile') . '=' . ew_QuotedValue($rs['id_profile'], $this->id_profile->FldDataType) . ' AND ';
     $SQL .= ew_QuotedName('stat_date') . '=' . ew_QuotedValue($rs['stat_date'], $this->stat_date->FldDataType) . ' AND ';
     if (substr($SQL, -5) == " AND ") {
         $SQL = substr($SQL, 0, strlen($SQL) - 5);
     }
     if ($this->CurrentFilter != "") {
         $SQL .= " AND " . $this->CurrentFilter;
     }
     return $SQL;
 }
Example #20
0
 function ParentUserIDList($userid)
 {
     $result = "";
     // Own record
     if (trim(strval($userid)) == strval(CurrentUserID())) {
         if (strval(CurrentParentUserID()) != "") {
             $result = ew_QuotedValue(CurrentParentUserID(), EW_DATATYPE_NUMBER);
         }
         return $result;
     }
     // One level only, must be CurrentUserID
     if (!EW_USER_ID_IS_HIERARCHICAL) {
         return ew_QuotedValue(CurrentUserID(), EW_DATATYPE_NUMBER);
     } else {
         // Hierarchical, all users except userid
         $ar = $this->UserID;
         $len = count($ar);
         for ($i = 0; $i < $len; $i++) {
             if (strval($ar[$i]) != trim(strval($userid))) {
                 if ($result != "") {
                     $result .= ", ";
                 }
                 $result .= ew_QuotedValue($ar[$i], EW_DATATYPE_NUMBER);
             }
         }
         return $result;
     }
 }
 function DeleteSQL(&$rs, $where = "")
 {
     $sql = "DELETE FROM " . $this->UpdateTable . " WHERE ";
     if ($rs) {
         if (array_key_exists('idempleado', $rs)) {
             ew_AddFilter($where, ew_QuotedName('idempleado') . '=' . ew_QuotedValue($rs['idempleado'], $this->idempleado->FldDataType));
         }
     }
     $filter = $this->CurrentFilter;
     ew_AddFilter($filter, $where);
     if ($filter != "") {
         $sql .= $filter;
     } else {
         $sql .= "0=1";
     }
     // Avoid delete
     return $sql;
 }
Example #22
0
        }
        $LnkDisp2 = $qs->getConvertedValue("ld2");
        // Link display field 2
        if (!is_numeric($LnkDisp2)) {
            exit;
        } elseif (intval($LnkDisp2) < -1 || intval($LnkDisp2) >= intval($LnkCount)) {
            exit;
        }
        $LnkFldType = $qs->getConvertedValue("lft");
        // Link field data type
    }
    if ($Sql != "") {
        if ($Value != "") {
            $arValue = explode(",", $Value);
            for ($i = 0; $i < count($arValue); $i++) {
                $arValue[$i] = ew_QuotedValue($arValue[$i], $LnkFldType);
            }
            $Sql = str_replace("@FILTER_VALUE", implode(",", $arValue), $Sql);
        }
        GetLookupValues($Sql);
    }
}
function GetLookupValues($Sql)
{
    global $LnkType, $LnkFld, $LnkCount, $LnkDisp1, $LnkDisp2;
    $conn = ew_Connect();
    if ($rs = $conn->Execute($Sql)) {
        $rsarr = $rs->GetRows();
        $rs->Close();
    }
    $conn->Close();
 function GetUserIDSubquery(&$fld, &$masterfld)
 {
     global $conn;
     $sWrk = "";
     $sSql = "SELECT " . $masterfld->FldExpression . " FROM `gastos_mantenimientos`";
     $sFilter = $this->AddUserIDFilter("");
     if ($sFilter != "") {
         $sSql .= " WHERE " . $sFilter;
     }
     // Use subquery
     if (EW_USE_SUBQUERY_FOR_MASTER_USER_ID) {
         $sWrk = $sSql;
     } else {
         // List all values
         if ($rs = $conn->Execute($sSql)) {
             while (!$rs->EOF) {
                 if ($sWrk != "") {
                     $sWrk .= ",";
                 }
                 $sWrk .= ew_QuotedValue($rs->fields[0], $masterfld->FldDataType);
                 $rs->MoveNext();
             }
             $rs->Close();
         }
     }
     if ($sWrk != "") {
         $sWrk = $fld->FldExpression . " IN (" . $sWrk . ")";
     }
     return $sWrk;
 }
Example #24
0
 function DeleteSQL(&$rs)
 {
     $SQL = "DELETE FROM `patient_main` WHERE ";
     $SQL .= EW_DB_QUOTE_START . 'PatientMainNo' . EW_DB_QUOTE_END . '=' . ew_QuotedValue($rs['PatientMainNo'], $this->PatientMainNo->FldDataType) . ' AND ';
     if (substr($SQL, -5) == " AND ") {
         $SQL = substr($SQL, 0, strlen($SQL) - 5);
     }
     if ($this->CurrentFilter != "") {
         $SQL .= " AND " . $this->CurrentFilter;
     }
     return $SQL;
 }
 function BuildBasicSearchSql(&$Where, &$Fld, $Keyword)
 {
     $sFldExpression = $Fld->FldVirtualExpression != "" ? $Fld->FldVirtualExpression : $Fld->FldExpression;
     $lFldDataType = $Fld->FldIsVirtual ? EW_DATATYPE_STRING : $Fld->FldDataType;
     if ($lFldDataType == EW_DATATYPE_NUMBER) {
         $sWrk = $sFldExpression . " = " . ew_QuotedValue($Keyword, $lFldDataType);
     } else {
         $sWrk = $sFldExpression . " LIKE " . ew_QuotedValue("%" . $Keyword . "%", $lFldDataType);
     }
     if ($Where != "") {
         $Where .= " OR ";
     }
     $Where .= $sWrk;
 }
 function DeleteSQL(&$rs, $where = "")
 {
     $sql = "DELETE FROM " . $this->UpdateTable . " WHERE ";
     if ($rs) {
         if (array_key_exists('codigo_bodega', $rs)) {
             ew_AddFilter($where, ew_QuotedName('codigo_bodega') . '=' . ew_QuotedValue($rs['codigo_bodega'], $this->codigo_bodega->FldDataType));
         }
         if (array_key_exists('Estanteria_Id', $rs)) {
             ew_AddFilter($where, ew_QuotedName('Estanteria_Id') . '=' . ew_QuotedValue($rs['Estanteria_Id'], $this->Estanteria_Id->FldDataType));
         }
         if (array_key_exists('Seccion_id', $rs)) {
             ew_AddFilter($where, ew_QuotedName('Seccion_id') . '=' . ew_QuotedValue($rs['Seccion_id'], $this->Seccion_id->FldDataType));
         }
     }
     $filter = $this->CurrentFilter;
     ew_AddFilter($filter, $where);
     if ($filter != "") {
         $sql .= $filter;
     } else {
         $sql .= "0=1";
     }
     // Avoid delete
     return $sql;
 }
 function DeleteSQL(&$rs, $where = "", $curfilter = TRUE)
 {
     $sql = "DELETE FROM " . $this->UpdateTable . " WHERE ";
     if (is_array($where)) {
         $where = $this->ArrayToFilter($where);
     }
     if ($rs) {
         if (array_key_exists('CARD_TYPE_ID', $rs)) {
             ew_AddFilter($where, ew_QuotedName('CARD_TYPE_ID', $this->DBID) . '=' . ew_QuotedValue($rs['CARD_TYPE_ID'], $this->CARD_TYPE_ID->FldDataType, $this->DBID));
         }
     }
     $filter = $curfilter ? $this->CurrentFilter : "";
     ew_AddFilter($filter, $where);
     if ($filter != "") {
         $sql .= $filter;
     } else {
         $sql .= "0=1";
     }
     // Avoid delete
     return $sql;
 }
Example #28
0
 function DeleteSQL(&$rs)
 {
     $SQL = "DELETE FROM `t_pays` WHERE ";
     $SQL .= ew_QuotedName('id') . '=' . ew_QuotedValue($rs['id'], $this->id->FldDataType) . ' AND ';
     if (substr($SQL, -5) == " AND ") {
         $SQL = substr($SQL, 0, strlen($SQL) - 5);
     }
     if ($this->CurrentFilter != "") {
         $SQL .= " AND " . $this->CurrentFilter;
     }
     return $SQL;
 }
 function BuildBasicSearchSql(&$Where, &$Fld, $arKeywords, $type)
 {
     $sDefCond = $type == "OR" ? "OR" : "AND";
     $sCond = $sDefCond;
     $arSQL = array();
     // Array for SQL parts
     $arCond = array();
     // Array for search conditions
     $cnt = count($arKeywords);
     $j = 0;
     // Number of SQL parts
     for ($i = 0; $i < $cnt; $i++) {
         $Keyword = $arKeywords[$i];
         $Keyword = trim($Keyword);
         if (EW_BASIC_SEARCH_IGNORE_PATTERN != "") {
             $Keyword = preg_replace(EW_BASIC_SEARCH_IGNORE_PATTERN, "\\", $Keyword);
             $ar = explode("\\", $Keyword);
         } else {
             $ar = array($Keyword);
         }
         foreach ($ar as $Keyword) {
             if ($Keyword != "") {
                 $sWrk = "";
                 if ($Keyword == "OR" && $type == "") {
                     if ($j > 0) {
                         $arCond[$j - 1] = "OR";
                     }
                 } elseif ($Keyword == EW_NULL_VALUE) {
                     $sWrk = $Fld->FldExpression . " IS NULL";
                 } elseif ($Keyword == EW_NOT_NULL_VALUE) {
                     $sWrk = $Fld->FldExpression . " IS NOT NULL";
                 } elseif ($Fld->FldDataType != EW_DATATYPE_NUMBER || is_numeric($Keyword)) {
                     $sFldExpression = $Fld->FldVirtualExpression != $Fld->FldExpression ? $Fld->FldVirtualExpression : $Fld->FldBasicSearchExpression;
                     $sWrk = $sFldExpression . ew_Like(ew_QuotedValue("%" . $Keyword . "%", EW_DATATYPE_STRING));
                 }
                 if ($sWrk != "") {
                     $arSQL[$j] = $sWrk;
                     $arCond[$j] = $sDefCond;
                     $j += 1;
                 }
             }
         }
     }
     $cnt = count($arSQL);
     $bQuoted = FALSE;
     $sSql = "";
     if ($cnt > 0) {
         for ($i = 0; $i < $cnt - 1; $i++) {
             if ($arCond[$i] == "OR") {
                 if (!$bQuoted) {
                     $sSql .= "(";
                 }
                 $bQuoted = TRUE;
             }
             $sSql .= $arSQL[$i];
             if ($bQuoted && $arCond[$i] != "OR") {
                 $sSql .= ")";
                 $bQuoted = FALSE;
             }
             $sSql .= " " . $arCond[$i] . " ";
         }
         $sSql .= $arSQL[$cnt - 1];
         if ($bQuoted) {
             $sSql .= ")";
         }
     }
     if ($sSql != "") {
         if ($Where != "") {
             $Where .= " OR ";
         }
         $Where .= "(" . $sSql . ")";
     }
 }
Example #30
0
 function UpdateSQL(&$rs, $where = "", $curfilter = TRUE)
 {
     $sql = "UPDATE " . $this->UpdateTable . " SET ";
     foreach ($rs as $name => $value) {
         if (!isset($this->fields[$name]) || $this->fields[$name]->FldIsCustom) {
             continue;
         }
         $sql .= $this->fields[$name]->FldExpression . "=";
         $sql .= ew_QuotedValue($value, $this->fields[$name]->FldDataType, $this->DBID) . ",";
     }
     while (substr($sql, -1) == ",") {
         $sql = substr($sql, 0, -1);
     }
     $filter = $curfilter ? $this->CurrentFilter : "";
     if (is_array($where)) {
         $where = $this->ArrayToFilter($where);
     }
     ew_AddFilter($filter, $where);
     if ($filter != "") {
         $sql .= " WHERE " . $filter;
     }
     return $sql;
 }