コード例 #1
0
 /**
  * The mysql connection.
  * @return resource
  */
 public static function mysql()
 {
     if (is_null(self::$mysql)) {
         global $CP_PASSWD;
         self::$mysql = new mysqli('localhost', 'handle_bg', $CP_PASSWD, 'handle_625_beeldengeluid');
         if (!self::$mysql) {
             throw new CP_MySQL_Exception(mysqli_connect_error());
         }
     }
     return self::$mysql;
 }
コード例 #2
0
EOS
);
$statement->bind_param('ss', $key, $value);
foreach ($parampairs as $parampair) {
    list($key, $value) = $parampair;
    if ($p_mode == 'LIKE') {
        preg_match_all('/([^~]|~.|~)/s', $value, $matches);
        $value = implode(preg_replace(array('/%/', '/_/', '/^\\*/', '/^~(.+)/s'), array('\\%', '\\_', '%', '$1'), $matches[0]));
    }
    if (!$statement->execute()) {
        switch (CP_MySQL::mysql()->errno) {
            case 1139:
                REST::fatal(REST::HTTP_BAD_REQUEST, CP_MySQL::mysql()->error);
                break;
            default:
                throw new CP_MySQL_Exception(CP_MySQL::mysql()->error, CP_MySQL::mysql()->errno);
        }
    }
    $r_handle = null;
    $statement->bind_result($r_handle);
    $r_handles = array();
    while ($statement->fetch()) {
        $r_handles[$r_handle] = 1;
    }
    if ($handles === null) {
        $handles = $r_handles;
    } else {
        $handles = array_intersect_key($handles, $r_handles);
    }
}
ksort($handles);
コード例 #3
0
    /**
     * @param $handle string
     * @return bool
     * @todo optimization by preparsed statements.
     */
    public function delete()
    {
        $eschandle = CP_MySQL::escape_string($this->handle);
        CP_MySQL::real_query(<<<EOS
DELETE FROM `handles` WHERE `handle` = {$eschandle};
EOS
);
        return CP_MySQL::mysql()->affected_rows > 0;
    }