本文整理汇总了PHP中str_dbparams函数的典型用法代码示例。如果您正苦于以下问题:PHP str_dbparams函数的具体用法?PHP str_dbparams怎么用?PHP str_dbparams使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_dbparams函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSpeedDial
function getSpeedDial($card, &$dialnum)
{
global $a2b;
global $agi;
// SPEED DIAL HANDLER
if (($sp_prefix = getAGIconfig('speeddial_prefix', NULL)) != NULL) {
if (strncmp($dialnum, $sp_prefix, strlen($sp_prefix)) == 0) {
// translate the speed dial.
$QRY = str_dbparams($a2b->DBHandle(), "SELECT phone, name FROM speeddials WHERE card_id = %#1 AND speeddial = %2", array($card['id'], substr($dialnum, strlen($sp_prefix))));
$agi->conlog($QRY, 3);
$res = $a2b->DBHandle()->Execute($QRY);
// If the rate engine has anything to Notice/Warn, display that..
if ($notice = $a2b->DBHandle()->NoticeMsg()) {
$agi->verbose('DB:' . $notice, 2);
}
if (!$res) {
$agi->verbose('Speed Dial: query error!', 2);
$agi->conlog($a2b->DBHandle()->ErrorMsg(), 2);
if (getAGIconfig('say_errors', true)) {
$agi->stream_file('allison2', '#');
}
break;
} elseif ($res->EOF) {
$agi->verbose('Speed Dial: no result.', 2);
}
$arr_speeddial = $res->fetchRow();
$agi->conlog('Speed Dial : found ' . $arr_speeddial['phone'], 4);
$dialnum = $arr_speeddial['phone'];
}
}
}
示例2: Save
/** Just saves the params and timestamp as an alarm_run row */
public function Save($status = null)
{
$dbhandle = A2Billing::DBHandle();
global $verbose;
if ($status) {
$this->ar_status = $status;
}
if (empty($this->ar_status)) {
$this->ar_status = 1;
}
if ($this->ar_id) {
// update a previous alarm_run record
$qry = sql_dbparams($dbhandle, "UPDATE cc_alarm_run\n\t\t\t\tSET tmodify = now(), status = %#2, params = %!3\n\t\t\t\tWHERE id = %1;", array($this->ar_id, $this->ar_status, arr2url($this->ar_params)));
} else {
//no run record, insert
$qry = str_dbparams($dbhandle, "INSERT INTO cc_alarm_run(alid,status,params)\n\t\t\t\tVALUES(%#1,%#2,%!3);", array($this->id, $this->ar_status, arr2url($this->ar_params)));
}
$res = $dbhandle->Execute($qry);
if (!$res) {
echo "Cannot mark alarm-run: ";
echo $dbhandle->ErrorMsg() . "\n";
} elseif ($dbhandle->Affected_Rows() < 1) {
echo "Cannot update alarm run.\n";
}
if ($verbose > 1) {
$str = $dbhandle->NoticeMsg();
if ($str) {
echo $str . "\n";
}
}
}
示例3: getGroup2
/** Inserts some provisioning group
\return the id of the inserted record
*/
protected function getGroup2($confname, $name, $subname = NULL, $opts)
{
$qry = str_dbparams($this->dbhandle, 'INSERT INTO provision_group(categ,model,name, sub_name, options) ' . 'VALUES(%1,%2,%3,%!4,%#5) RETURNING id; ', array('spa-conf', $confname, $name, $subname, $opts));
$res = $this->dbhandle->Execute($qry);
if (!$res) {
$this->out(LOG_ERR, $this->dbhandle->ErrorMsg());
throw new Exception('Cannot insert into database.');
} elseif ($res->EOF) {
$this->out(LOG_ERR, "No rows inserted!");
}
$row = $res->fetchRow();
return $row['id'];
}
示例4: buildSearchClause
public function buildSearchClause(&$dbhandle, &$form, $search_exprs)
{
$val = $this->buildValue($form->getpost_dirty($this->fieldname), $form);
$mo_val = $form->getpost_dirty('use_' . $this->fieldname);
if (empty($mo_val)) {
$mo_val = 'no';
}
if (empty($this->fieldexpr)) {
$fldex = $this->fieldname;
} else {
$fldex = $this->fieldexpr;
}
if ($this->case_sensitive) {
$like = 'LIKE';
} else {
$like = 'ILIKE';
}
if ($val == null) {
switch ($mo_val) {
case 'no':
default:
return null;
case 'eq':
return "{$fldex} IS NULL";
case 'st':
case 'en':
return null;
}
} else {
switch ($mo_val) {
case 'eq':
if ($this->case_sensitive) {
return str_dbparams($dbhandle, "{$fldex} = %1", array($val));
} else {
return str_dbparams($dbhandle, "lower({$fldex}) = lower(%1)", array($val));
}
case 'st':
return str_dbparams($dbhandle, "{$fldex} {$like} %1 || '%%'", array($val));
case 'en':
return str_dbparams($dbhandle, "{$fldex} {$like} '%%' || %1", array($val));
case 'ct':
return str_dbparams($dbhandle, "{$fldex} {$like} '%%' || %1 || '%%'", array($val));
case 'no':
default:
return null;
}
}
}
示例5: update_mailing
function update_mailing(&$dbhandle, $id, $is_sent, $dbg)
{
if ($is_sent) {
$state = 3;
} else {
$state = 4;
}
$qry = str_dbparams($dbhandle, "UPDATE cc_mailings SET state = %#2 WHERE id = %1 ;", array($id, $state));
$res = $dbhandle->Execute($qry);
if ($dbg > 2) {
echo "Update query: " . $qry . "\n";
}
if (!$res) {
if ($dbg > 0) {
echo "Query Failed: " . $dbhandle->ErrorMsg() . "\n";
}
return false;
}
return true;
}
示例6: ProcessAlarm
function ProcessAlarm(AlmInstance $inst)
{
$dbhandle = A2Billing::DBHandle();
global $verbose;
if ($inst->ar_id) {
// we cannot handle previous instances
return;
}
$margin = $inst->alm_params['margin'];
if (!isset($margin)) {
$margin = 0.0;
}
$qry = str_dbparams($dbhandle, "SELECT cc_agent.id, credit, name, locale, email, climit, cc_alarm_run.id AS ar_id,\n\t\t\t\tcc_alarm_run.status AS ar_status\n\t\t\tFROM cc_agent LEFT JOIN cc_alarm_run ON ( cc_alarm_run.dataid = cc_agent.id\n\t\t\t\tAND cc_alarm_run.alid = %#1) \n\t\t\tWHERE (climit + credit ) < %#2 ;", array($inst->id, $margin));
if ($verbose > 2) {
echo "Query: " . $qry . "\n";
}
$res = $dbhandle->Execute($qry);
if (!$res) {
echo $dbhandle->ErrorMsg() . "\n";
} else {
if ($res->EOF) {
if ($verbose > 2) {
echo "All agents have credit.\n";
}
$inst->Save(1);
return;
}
}
$neg_agents = array();
while ($row = $res->fetchRow()) {
if ($verbose > 2) {
echo "Agent " . $row['name'] . " is low on credit.\n";
}
if (!empty($row['email'])) {
$this->sendMail('agent-low-credit', $row['email'], $row['locale'], array(credit => $row['credit'], climit => $row['climit']));
}
$neg_agents[] = $row['name'] . ": " . $row['credit'] . "/" . $row['climit'];
}
$this->sendSysMail('sys-agent-low-credit', $inst, array(low_agents => implode("\n", $neg_agents)));
$inst->Save();
}
示例7: genContent
public function genContent(&$outstream)
{
fwrite($outstream, "; Generated content\n\n");
while ($crd = $this->itemres->fetchRow()) {
foreach ($this->grprows as $grp) {
$line = '';
$qry = str_dbparams($this->dbhandle, "SELECT * FROM provisions " . "WHERE grp_id = %#1 ORDER BY metric;", array($grp['id']));
$this->out(LOG_DEBUG, "Query: {$qry}");
$pres = $this->dbhandle->Execute($qry);
if (!$pres) {
$this->out(LOG_ERR, $this->dbhandle->ErrorMsg());
throw new Exception("Cannot locate provision");
} elseif ($itemres->EOF) {
$this->out(LOG_WARNING, 'No rows for cc_card');
continue;
}
// Write a header like [name] ..
$line = '[';
if (!empty($grp['sub_name'])) {
$line .= str_alparams($grp['sub_name'], $crd);
} else {
$line .= $grp['name'];
}
$line .= "]\n";
fwrite($outstream, $line);
while ($row = $pres->fetchRow()) {
$line = '';
if (!empty($row['sub_name'])) {
$line = str_alparams($row['sub_name'], $crd);
} else {
$line = $row['name'];
}
$line .= '=';
$line .= str_alparams($row['valuef'], $crd);
$line .= "\n";
fwrite($outstream, $line);
}
fwrite($outstream, "\n");
}
}
}
示例8: login
function login($user, $pass)
{
global $FG_DEBUG;
$DBHandle = A2Billing::DBHandle();
$user = trim($user);
$pass = trim($pass);
if (strlen($user) == 0 || strlen($user) >= 50 || strlen($pass) == 0 || strlen($pass) >= 50) {
return false;
}
$nameclause = "";
if (DynConf::GetCfg(CUSTOMER_CFG, 'username_login', true)) {
$nameclause = "username = %1";
}
if (DynConf::GetCfg(CUSTOMER_CFG, 'useralias_login', false)) {
if (!empty($nameclause)) {
$nameclause .= ' OR ';
}
$nameclause .= "useralias = %1";
}
if (DynConf::GetCfg(CUSTOMER_CFG, 'email_login', false)) {
if (!empty($nameclause)) {
$nameclause .= ' OR ';
}
$nameclause .= "email = %1";
}
if (($cgrp = DynConf::GetCfg(CUSTOMER_CFG, 'cardgroup_only', null)) != null) {
$group_clause = ' AND grp = %#3';
}
$QUERY = str_dbparams($DBHandle, "SELECT id, username, status, currency, grp, language\n\t\t FROM cc_card WHERE ({$nameclause}) AND userpass = %2 {$group_clause} ;", array($user, $pass, $cgrp));
$res = $DBHandle->Execute($QUERY);
if (!$res) {
$errstr = $DBHandle->ErrorMsg();
if ($FG_DEBUG) {
echo $errstr . "<br>\n";
}
return 4;
}
if ($res->EOF) {
// no such user!
if ($FG_DEBUG > 1) {
echo "Query: {$QUERY} <br>";
}
return 1;
}
$row = $res->fetchRow();
if ($row['status'] != 1) {
return 0 - intval($row['status']);
}
// if( ACTIVATEDBYUSER==1 && $row [0][7] != "t" && $row [0][7] != "1" ) {
// return -2;
// }
return $row;
}
示例9: iam_csvdump
# Set the parameters: SQL Query, hostname, databasename, dbuser and password #
#####################################################################################################################
$dumpfile = new iam_csvdump();
# Call the CSV Dumping function and THAT'S IT!!!! A file named dump.csv is sent to the user for download #
#####################################################################################################################
if (strlen($id_tp) < 1) {
echo gettext("ERROR CSV EXPORT");
} else {
$log = new Logger();
$DBHandle = DbConnect();
$export_fields = array('dialprefix', 'destination', 'rateinitial');
$sql_str = "ABORT;";
switch ($export_style) {
case 'peer-full-csv':
array_push($export_fields, 'buyrate', 'buyrateinitblock', 'buyrateincrement', 'rateinitial', 'initblock', 'billingblock', 'connectcharge', 'disconnectcharge', 'stepchargea', 'chargea', 'timechargea', 'billingblocka', 'stepchargeb', 'chargeb', 'timechargeb', 'billingblockb', 'stepchargec', 'chargec', 'timechargec', 'billingblockc');
$sql_str = str_dbparams($DBHandle, 'SELECT ' . implode(', ', $export_fields) . ' FROM cc_ratecard WHERE idtariffplan = %1;', array($id_tp));
$log_str = "Ratecard #%0 exported in csv format, all fields in peer format";
$myfileName = "Ratecard_" . $tp_id;
$prolog = "# Export of tp #{$id_tp}\n";
$prolog .= "#fields: " . implode(';', $export_fields) . "\n";
break;
default:
echo "Wrong export style:" . $export_style . "\n<br>\n";
die;
}
$myfileName .= date("Y-m-d");
$log->insertLog($_SESSION["admin_id"], 2, "FILE EXPORTED", str_params($log_str, array($id_tp, $export_style)), '', $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI'], '');
$dumpfile->sep = ';';
$dumpfile->prolog = $prolog;
$dumpfile->dump($sql_str, $myfileName, "csv", DBNAME, USER, PASS, HOST, DB_TYPE);
DBDisconnect($DBHandle);
示例10: gen_all_agents
function gen_all_agents($dbh, $do_sip, $do_iax, &$err_msg)
{
global $FG_DEBUG;
global $A2B;
$ita = new Table('cc_agent', 'id, login,name');
if ($FG_DEBUG > 1) {
$ita->debug_st = 1;
}
$list_agent = $ita->Get_list($dbh, 'active = true', null, null, null, null);
if (!is_array($list_agent) || count($list_agent) == 0) {
$err_msg .= str_params(_("<p style='color: red'>No active agents found!<br>%1</p>"), array($dbh->ErrorMsg()), 1);
return false;
}
// These are put by default on a non-existing directory!
// This is intentional, since those files contain SIP/IAX passwords.
// they shouldn't be carelessly left in a world-readable dir.
if (isset($A2B->config['webui']['buddy_sip_agent'])) {
$buddy_sip = $A2B->config['webui']['buddy_sip_agent'];
} else {
$buddy_sip = "/tmp/a2billing/additional_sip.%1.conf";
}
if (isset($A2B->config['webui']['buddy_iax_agent'])) {
$buddy_iax = $A2B->config['webui']['buddy_iax_agent'];
} else {
$buddy_iax = "/tmp/a2billing/additional_iax.%1.conf";
}
$succ = 0;
foreach ($list_agent as $ag) {
$hdr_lines = "; Configuration for " . $ag[2] . "\n";
if ($do_sip) {
$fname = str_params($buddy_sip, $ag);
$qclause = str_dbparams($dbh, "name IN (SELECT callerid FROM cc_booth WHERE agentid = %1)", array($ag[0]));
if (gen_userdata($dbh, $fname, 'cc_sip_buddies', $qclause, $err_msg, $hdr_lines)) {
$succ++;
}
}
if ($do_iax) {
$fname = str_params($buddy_iax, $ag);
$qclause = str_dbparams($dbh, "name IN (SELECT callerid FROM cc_booth WHERE agentid = %1)", array($ag[0]));
if (gen_userdata($dbh, $fname, 'cc_iax_buddies', $qclause, $err_msg, $hdr_lines)) {
$succ++;
}
}
}
$co = 0;
if ($do_sip) {
$co += count($list_agent);
}
if ($do_iax) {
$co += count($list_agent);
}
$err_msg .= str_params(_("<p style='color: blue'>Agent config files: %#1 of %#2 files created.</p>"), array($succ, $co), 1);
return true;
}
示例11: db_fetchone
function db_fetchone($qry, $parms = NULL)
{
if ($parms) {
$res = $this->dbh->Execute(str_dbparams($this->dbh, $qry, $parms));
} else {
$res = $this->dbh->Execute($qry);
}
if (!$res) {
$this->out(LOG_ERR, "Qry failed: {$qry} (" . implode(', ', $parms) . ')');
$this->out(LOG_ERR, $this->dbh->ErrorMsg());
throw new Exception("Query failed: {$qry}");
}
$row = $res->FetchRow();
if (!$row) {
throw new NoDataException("Query: \"{$qry}\": No results");
}
return $row;
}
示例12: formatDialstring_peer
function formatDialstring_peer($dialn, &$route, &$card, $do_param = true)
{
global $a2b;
global $agi;
$dbhandle = $a2b->DBHandle();
if ($route['stripdigits'] > 0) {
$dialnum = substr($route['dialstring'], $route['stripdigits']);
} else {
$dialnum = $route['dialstring'];
}
$bind_str = '%dialtech/%dialname';
switch ($route['trunkfmt']) {
case 4:
$qry = str_dbparams($dbhandle, 'SELECT dialtech, dialname FROM cc_dialpeer_local_v ' . 'WHERE useralias = %1', array($dialnum));
$bind_str = '%dialtech/%dialname';
if (strlen($route['providertech'])) {
$qry .= str_dbparams($dbhandle, ' AND dialtech = %1', array($route['providertech']));
}
// If the trunk specifies an "ip", aliases among the corresponding numplan will be queried
// else, the numplan *must* be the same with that of the card.
// It would be wrong not to specify a numplan, since aliases accross them are not unique!
if (strlen($route['providerip'])) {
$qry .= str_dbparams($dbhandle, ' AND numplan_name = %1', array($route['providerip']));
} else {
$qry .= str_dbparams($dbhandle, ' AND numplan = %#1', array($card['numplan']));
}
break;
case 6:
// hardcode search into same numplan!
$qry = str_dbparams($dbhandle, 'SELECT * FROM cc_dialpeer_remote_v ' . 'WHERE useralias = %1 AND numplan = %#2', array($dialnum, $card['numplan']));
$bind_str = $route['providertech'] . '/' . $route['providerip'];
break;
case 7:
case 15:
$dnum = explode('-', $dialnum);
if ($dnum[0] == 'L') {
$dnum[0] = $card['numplan'];
}
$qry = str_dbparams($dbhandle, 'SELECT dialtech, dialname FROM cc_dialpeer_local_v ' . 'WHERE useralias = %2 AND numplan = %#1 ', $dnum);
if (strlen($route['providertech'])) {
$qry .= str_dbparams($dbhandle, ' AND dialtech = %1', array($route['providertech']));
}
$bind_str = '%dialtech/%dialname';
$agi->conlog("Query: {$qry}", 3);
break;
case 8:
$dnum = explode('-', $dialnum);
if ($dnum[0] == 'L') {
$dnum[0] = $card['numplan'];
}
$qry = str_dbparams($dbhandle, 'SELECT * FROM cc_dialpeer_remote_v ' . 'WHERE useralias = %2 AND numplan = %#1', $dnum);
$agi->conlog("Query: {$qry}", 3);
$bind_str = $route['providertech'] . '/' . $route['providerip'];
break;
}
$qry .= ';';
//$agi->conlog("Find peer from ". $qry,4);
if (!$bind_str) {
return false;
}
$res = $dbhandle->Execute($qry);
if (!$res) {
$agi->verbose('Cannot dial peer: ' . $dbhandle->ErrorMsg());
if (getAGIconfig('say_errors', true)) {
$agi->stream_file('allison2', '#');
}
return false;
}
if ($res->EOF) {
$agi->verbose("Peer dial: cannot find peer " . $dialnum, 2);
//$agi-> stream_file("prepaid-dest-unreachable",'#');
return null;
}
// Feature! If more than one registrations exist, call all of them in
// parallel!
$peer_rows = array();
while ($row = $res->fetchRow()) {
$peer_rows[] = str_alparams($bind_str, $row);
}
$str = '';
if ($do_param) {
if ($agi->astmajor == "1.6") {
$str .= getAGIconfig('dialcommand_param', ',60,iL(%timeout)%param');
} else {
$str .= getAGIconfig('dialcommand_param', '|60|iL(%timeout)%param');
}
$str = str_alparams($str, array('dialnum' => $dialnum, 'dialnumber' => $dialn, 'dialstring' => $route['dialstring'], 'destination' => $route['destination'], 'trunkprefix' => $route['trunkprefix'], 'tech' => $route['providertech'], 'providerip' => $route['providerip'], 'prefix' => $route['prefix'], 'param' => $route['trunkparm'], 'cardnum' => $card['username'], 'stimeout' => $route['tmout'], 'timeout' => 1000 * $route['tmout']));
}
return implode('&', $peer_rows) . $str;
}
示例13: buildSearchClause
public function buildSearchClause(&$dbhandle, $form, $search_exprs)
{
$val = $this->buildValue($form->getpost_dirty($this->fieldname), $form);
if (empty($this->fieldexpr)) {
$fldex = $this->fieldname;
} else {
$fldex = $this->fieldexpr;
}
if (is_array($search_exprs) && isset($search_exprs[$this->fieldname])) {
$sex = $search_exprs[$this->fieldname];
} else {
$sex = '=';
}
//what's on *your* mind?
if ($val == null) {
switch ($sex) {
// Assume NULL -> 0 ..
case '<>':
case '!=':
case '>':
return $fldex . ' IS NOT NULL';
case '<':
return 'false';
case '>=':
return 'true';
case '=':
case '<=':
default:
return $fldex . ' IS NULL';
}
} else {
return str_dbparams($dbhandle, "{$fldex} {$sex} %1", array($val));
}
}
示例14: ReleaseCard
}
$played_nec = true;
ReleaseCard($card);
$card = null;
continue;
}
$played_nec = false;
$dialnum = getDialNumber($card, $num_try == 0);
if ($dialnum === false) {
$agi->stream_file('prepaid-invalid-digits', '#');
continue;
}
$agi->conlog("Dial number: " . $dialnum, 4);
// CHECK SPEEDDIAL
getSpeedDial($card, $dialnum);
$QRY = str_dbparams($a2b->DBHandle(), 'SELECT * FROM RateEngine3(%#1, %2, %#3, now(), %4);', array($card['tgid'], $dialnum, $card['numplan'], $card_money['base']));
$agi->conlog($QRY, 3);
$res = $a2b->DBHandle()->Execute($QRY);
// If the rate engine has anything to Notice/Warn, display that..
if ($notice = $a2b->DBHandle()->NoticeMsg()) {
$agi->verbose('DB:' . $notice, 2);
}
if (!$res) {
$agi->verbose('Rate engine: query error!', 2);
$agi->conlog($a2b->DBHandle()->ErrorMsg(), 2);
if (getAGIconfig('say_errors', true)) {
$agi->stream_file('allison2', '#');
}
ReleaseCard($card);
$card = null;
break;
示例15: buildUpdate
public function buildUpdate(&$ins_arr, &$form)
{
if (!$this->does_edit) {
return;
}
$ins_arr[] = str_dbparams($form->a2billing->DBHandle(), $this->fieldname . " = conv_currency_to( %1, %2)", array($this->buildValue($form->getpost_dirty($this->fieldname), $form), $form->a2billing->currency));
}