Announcement

Collapse
No announcement yet.

sc_select_where() or method to clear where?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • sc_select_where() or method to clear where?

    I have an app that needs to use express search and dynamically filter by customer as set by parent app. The issue is using sc_select_where(add) results in this sql format.
    select from tbl
    where col1 like"%val%", col2 like"%val%",col3 like"%val%" and cust = [cust];

    Unfortunately this format still returns all customers. I need to format like:
    select from tbl
    where cust = [cust] and (col1 like"%val%", col2 like"%val%",col3 like"%val%");

    While this returns the correct value my function cannot get sc to query this way.

    My func:
    if (empty({sc_where_current}))
    {
    sc_select_where(add) = " where cust_id = ".$usr_num."";
    }
    else
    {
    // strip where str from current query
    $modQ = substr({sc_where_current},6);
    //trying to clear query
    {sc_where_orig}="";
    {sc_where_current}="";
    // new query properly formatted
    sc_select_where() = "WHERE cust_id = ".$usr_num." AND (".$modQ.")";

    // echo new query for verification.
    echo({sc_where_current});
    }
    So this echos out sc_where_current as the sql string in my second example but sc does not use this query.

    Is there a method similar to sc_select_where(add); that would effectively replace the select where clause with my restructured query string?
    Thanks

  • #2
    I have the same issue. Is there any solution?
    Gökhan Sönmez

    Comment


    • #3
      Hi,
      if you want total flexibility, just use a global variable for your where-clause.
      Fill in your SQL statement for your grid without the condition.

      SELECT * FROM 'yourtable' WHERE [glo_where]

      In the onScriptInit section create your condition.

      [glo_where] = 1; //make sure this variable isn't empty

      If($something == true)
      {
      [glo_where] = "stick what ever you want in it"; //well, it should be something useful
      }

      That's it. See the magic happen.

      Later on
      jsb

      Comment


      • #4
        Originally posted by jsbinca View Post
        [glo_where] = 1; //make sure this variable isn't empty
        I recommend, that you init the [glo_where] Variable with "1=1". That's always true and no errors ...
        Best regards: - Reinhard -

        I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

        Comment


        • #5
          Hi Reinhard,
          you're up late, aren't you?

          jsb

          Comment


          • #6
            Originally posted by jsbinca View Post
            SELECT * FROM 'yourtable' WHERE [glo_where]
            Thank you!
            Gökhan Sönmez

            Comment

            Working...
            X