Announcement

Collapse
No announcement yet.

Get [global_variable] in external library is it possible?

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

  • Get [global_variable] in external library is it possible?

    is it possible to access the global variables ([sc_glo_server],[sc_glo_user],[sc_glo_pass],[sc_glo_db]) from an external library ?

    external library code:

    function mysqli($query){

    $mysqli = mysqli_connect([sc_glo_server], [sc_glo_user], sc_decode([sc_glo_pass]), [sc_glo_db]) or die('Unable to Connect');

    if ($mysqli->connect_error) {
    die('Error : (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
    }
    $fetch1 = $mysqli->query($query) or trigger_error($mysqli->error);
    $rows1 = array();
    while ($r = mysqli_fetch_assoc($fetch1)) {
    $rows1[] = $r;
    }
    return $rows1;

    }

  • #2
    You coud pass the DB object created by the SC app that is using the connection: $this->Db.

    Something like this usually works for me:

    code in app:
    Code:
    my_external_function($this->Db);

    code in external library:
    Code:
    function my_external_function($db_obj)
    {
           $sql = "....";  // your select query
           $rs = $db_obj->Execute($sql);
           // recorset handling code here
           ....
     }

    Comment

    Working...
    X