Example #1
0
 protected final function init($sqltable, $common)
 {
     $sqltable = sub_prefix($sqltable);
     $this->silent_mode = False;
     $this->keybuffer = array();
     $selector = "WHERE ";
     $fields = "";
     foreach ($common as $field => $val) {
         $selector .= "`{$field}` = ? AND ";
         $fields .= ", `{$field}`";
         $this->common_vals[] = $val;
     }
     $this->stmt_get = prep_stmt("SELECT `value` FROM `{$sqltable}` {$selector} `key` = ?");
     $this->stmt_unset = prep_stmt("DELETE FROM `{$sqltable}` {$selector} `key` = ?");
     $this->stmt_update = prep_stmt("UPDATE `{$sqltable}` SET `value` = ? {$selector} `key` = ?");
     $this->stmt_create = prep_stmt("INSERT INTO `{$sqltable}` (`key`, `value` {$fields}) VALUES (?,?" . str_repeat(",?", count($common)) . ")");
     $get_keys = prep_stmt("SELECT `key` FROM `{$sqltable}` {$selector} 1");
     $get_keys->execute($this->common_vals);
     while ($sqlrow = $get_keys->fetch()) {
         $this->keybuffer[] = $sqlrow["key"];
     }
     $this->counter = 0;
 }
Example #2
0
function prep_stmt($q)
{
    global $db_con;
    return $db_con->prepare(sub_prefix($q));
}