function request_read_after(&$data) { $q = "\n\t\tselect\tG.name\n\t\tfrom\t_group\t\tG\n\t\t,\t\t_user_group\tUG\n\t\twhere\tUG._group_id\t= G.id\n\t\tand\t\tUG._user_id\t\t= ?\n\t\t"; Jaring::$_db_ps = Jaring::$_db->prepare($q); foreach ($data as &$d) { Jaring::$_db_ps->execute(array($d["id"])); $rs = Jaring::$_db_ps->fetchAll(PDO::FETCH_COLUMN, 0); Jaring::$_db_ps->closeCursor(); // add empty password. $d["password"] = ""; // add user's group name to result set. $d["group_name"] = implode(",", $rs); } }
function update_logo() { // Update logo. $s = Jaring::request_upload_check_err("logo"); if (false === $s) { if ($_FILES["logo"]["error"] === UPLOAD_ERR_NO_FILE) { return true; } return false; } $id = $_POST["id"]; $q = "update _profile set logo_type = ? , logo = ? where id = ?"; Jaring::$_db_ps = Jaring::$_db->prepare($q); $fp = fopen($_FILES["logo"]["tmp_name"], "rb"); $i = 1; Jaring::$_db_ps->bindParam($i++, $_FILES["logo"]["type"]); Jaring::$_db_ps->bindParam($i++, $fp, PDO::PARAM_LOB); Jaring::$_db_ps->bindParam($i++, $id); Jaring::$_db_ps->execute(); return true; }
<?php /* Copyright 2014 Mhd Sulhan Authors: - mhd.sulhan (m.shulhan@gmail.com) */ $no_cookies = true; require_once "../../../init.php"; Jaring::db_init(); $q = "select logo_type, logo from _profile where id = ?"; Jaring::$_db_ps = Jaring::$_db->prepare($q); Jaring::$_db_ps->execute(array($_GET["_profile_id"])); Jaring::$_db_ps->bindColumn(1, $type, PDO::PARAM_STR); Jaring::$_db_ps->bindColumn(2, $lob, PDO::PARAM_LOB); Jaring::$_db_ps->fetch(PDO::FETCH_BOUND); header("Content-Type: {$type}"); echo $lob;
public static function db_prepare_delete($table, $fields) { $qdelete = " delete from {$table}"; $qwhere = " where " . self::db_prepare_fields($fields); self::$_db_ps = self::$_db->prepare($qdelete . $qwhere); }