[OpenSIPS-Users] is this valid naming for avps - $avp($var(i))

Darren DeLitizia ddgiants at gmail.com
Fri Dec 16 05:47:56 CET 2011


Is this valid naming for avp's - $avp($var(i))

I am trying to loop through exec_avp results as I will never know how many
rows are being returned. It is in a startup route and I am using a while
statement to loop through. It is not recognizing naming. $avp($avp(i))
always returns NULL while something like $avp(2) will return the data

Tx
DD

  exec_avp("/usr/bin/php /usr/local/etc/opensips/name_of_script.php
ips");#gets list of ips and other carrier info
  if (is_avp_set("$avp(1)")) {
    $var(x) = $avp(1); #$avp(1) is the amount of rows returned so I know
how many to loop through
    $var(x) = $(var(x){s.int}) + 1;
    avp_delete("$avp(1)");
    $avp(i) = 2;
    while($avp(i) <= $var(x)) {
      xlog("TEST -- $avp(i)\n");
      xlog("TEST -- $avp($avp(i))\n"); #
      $avp(ip) = $(avp($var(i)){s.select,0,;});
      $avp(carrier_ids) = $(avp($var(i)){s.select,1,;});
      $avp(route_types) = $(avp($var(i)){s.select,2,;});
      $avp(carrier_names) = $(avp($var(i)){s.select,0,;});
      cache_store("local", "ips_carrier_ids_$avp(ip)",
"$avp(carrier_ids)");#
      cache_store("local", "ips_carrier_names_$avp(ip)",
"$avp(carrier_names)");#
      cache_store("local", "ips_carrier_types_$avp(ip)",
"$avp(route_types)");#
      avp_delete("$avp($var(i))");
      $avp(i) = $avp(i) + 1;
    }
  }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20111215/24d6a0c7/attachment-0001.htm>


More information about the Users mailing list