public static function ThemDoiTuong($tenDoiTuong) { $result = TRUE; $identity = 0; try { if (!ConnectDB::OpenConnection()) { throw new Exception("Không thể kết nối với cơ sở dữ liệu.\n", $code); return FALSE; } //$strSQL =sprintf("CALL spThemDoiTuong('%s')", $tenDoiTuong); //$result = mysql_query($strSQL, ConnectDB::$mLink); $strSQL = "insert into doi_tuong(`MaDoiTuong`, `TenDoiTuong`) values ('','{$tenDoiTuong}')"; //echo $strSQL; $result = mysql_query($strSQL, ConnectDB::$mLink); $identity = mysql_insert_id(); ConnectDB::CloseConnection(); } catch (Exception $e) { $result = FALSE; } if ($strSQL) { return $identity; // trả về dòng đối tượng vừa được insert vào } else { $result = false; return $result; // nếu thực thi hok được thì trả về false } }
function __construct() { try { self::$DBH = new PDO("mysql:host={$this->host};dbname={$this->dbname}", $this->user, $this->pass); } catch (PDOException $e) { die('Подключение не удалось: ' . $e->getMessage()); } }
function __construct() { try { self::$DBH = new PDO("mysql:host={$this->host};dbname={$this->dbname}", $this->user, $this->pass); self::$DBH->exec("set names utf8"); } catch (PDOException $e) { die('Ошибка: ' . $e->getMessage()); } }
function RequsetData($gender) { $sql = "SELECT `message`, `obj_id`, `created_time` FROM `beauty_nttu` WHERE `message` LIKE '%【" . $gender . "】%'"; $conn = new ConnectDB(); $link = $conn->InitialDB(); $data = $conn->ProcessData($link, $sql, array(), "get-image-id"); $conn->ConnectClose($link); $str = '<h2>資料來源:<a href="https://www.facebook.com/BeautyNTTU/?fref=ts" target="_blank">表特東大</a></h2> <p>僅提供瀏覽,欣賞</p>'; $len = count($data); for ($index = 0; $index < $len; $index++) { $message = $data[$index]["message"]; $normal = "https://graph.facebook.com/" . $data[$index]["obj_id"] . "/picture?type=normal"; $thumbnail = "https://graph.facebook.com/" . $data[$index]["obj_id"] . "/picture?type=thumbnail"; $str .= '<a title="' . $message . '" class="swipebox" href="' . $normal . '">'; $str .= '<img src="' . $thumbnail . '" alt="image" class="img-rounded">'; $str .= '</a>'; } return $str; }
public static function OpenConnection() { ConnectDB::$mLink = @mysql_connect(ConnectDB::$mHost, ConnectDB::$mLoginName, ConnectDB::$mPassword); //ConnectDB::$mHost, ConnectDB::$mLoginName, ConnectDB::$mPassword); if (!ConnectDB::$mLink) { return false; } mysql_query("set names 'utf8'", ConnectDB::$mLink); if (!@mysql_select_db(ConnectDB::$mDBName, ConnectDB::$mLink)) { return false; } return true; }
public static function CapNhatLoaiSP($tenLoaiSP, $maLoaiSP) { $result = true; ConnectDB::OpenConnection(); try { if (!ConnectDB::OpenConnection()) { return false; } $strSQL = "UPDATE `loai_san_pham` SET `TenLoaiSP`= '{$tenLoaiSP}'\r\n\t\t\t\t\t\tWHERE `MaLoaiSP` = {$maLoaiSP} "; $result = mysql_query($strSQL, ConnectDB::$mLink); ConnectDB::CloseConnection(); } catch (Exception $e) { $result = false; } return $result; }
public static function LayDSLoaiNguoiDung() { $lstLoaiNguoiDung = array(); try { if (!ConnectDB::OpenConnection()) { return null; } $strSql = "SELECT * FROM `loai_nguoi_dung`;"; $result = mysql_query($strSql, ConnectDB::$mLink); if ($result == false) { return null; } while ($row = mysql_fetch_array($result)) { $LoaiNDDto = new LoaiNguoiDungDTO(); $LoaiNDDto->MaLoaiND = $row["MaLoaiND"]; $LoaiNDDto->LoaiNguoiDung = $row["LoaiNguoiDung"]; array_push($lstLoaiNguoiDung, $LoaiNDDto); } ConnectDB::CloseConnection(); } catch (Exception $e) { $lstLoaiNguoiDung = null; } return $lstLoaiNguoiDung; }
public static function TinhSoSaoTBCuaMotDoiTuong($maDoiTuong) { $soSaoTB = 0; try { if (!ConnectDB::OpenConnection()) { return false; } $strSQL = "select * from Likes where MaDoiTuong = {$maDoiTuong};"; $result = mysql_query($strSQL, ConnectDB::$mLink); if (!$result || mysql_num_rows($result) <= 0) { return 0; } $numRow = mysql_num_rows($result); $tongSoSao = 0; while ($row = mysql_fetch_array($result)) { $tongSoSao = $tongSoSao + $row["SoSao"]; } ConnectDB::CloseConnection(); $soSaoTB = $tongSoSao / $numRow; } catch (Exception $e) { $soSaoTB = 0; } return $soSaoTB; }
/** * Lấy ds DDH của một gian hàng, sắp theo thứ tự thời gian giảm dần * tùy chọn $trangThai: 1-chờ xử lý, 2-đã liên hệ, 3-đã hoàn tất, 4-hủy, 0- lấy tất cả * Thu Hà 20/6/2011 */ public static function LayDSDDHTheoMaDDH_TrangThai($maGianHang, $trangThai) { $dsDDH = true; try { if (!ConnectDB::OpenConnection()) { return false; } $strSql = "SELECT * FROM `don_dat_hang` \r\n\t\t\t\t\t WHERE `MaGianHang`= {$maGianHang}"; if ($trangThai == 0) { $strSql = ";"; } else { $strSql = "AND TrangThai = {$trangThai};"; } $result = mysql_query($strSql, ConnectDB::$mLink); if (!$result) { return null; } while ($row = mysql_fetch_array($result)) { $donDatHangDto = new DonDatHangDTO(); $donDatHangDto->MaDDH = $row["MaDDH"]; $donDatHangDto->MaGianHang = $row["MaGianHang"]; $donDatHangDto->MaNguoiDung = $row["MaNguoiDung"]; $donDatHangDto->TrangThai = $row["TrangThai"]; $donDatHangDto->GhiChu = $row["GhiChu"]; $donDatHangDto->NgayDat = $row["NgayDat"]; $donDatHangDto->NgayHuy = $row["NgayHuy"]; array_push($dsDDH, $donDatHangDto); } ConnectDB::CloseConnection(); } catch (Exception $e) { $dsDDH = null; } return $dsDDH; }
public function __construct($args) { parent::__construct($args); }
public function excluir() { $id = $_GET['id']; try { ConnectDB::open(); $funcionarioDAO = new FuncionarioDAO(); $funcionario = $funcionarioDAO->load($id); $funcionarioDAO->excluir($funcionario); ConnectDB::close(); header('location: index.php?c=FuncionarioController&m=index'); } catch (PDOException $e) { echo $e->getMessage(); ConnectDB::close(); } }
/** * Lấy ds sự kiện trong khoảng thời gian * Edit by Thu Hà 20/6/2011 */ public static function LayDanhSachSuKienTrongKhoangThoiGian($thoiGianBD, $thoiGianKT) { $lstSuKien = array(); try { if (!ConnectDB::OpenConnection()) { return false; } $strSQL = "SELECT * FROM su_kien \r\n\t\t\t\t\t\tWHERE DATEDIFF(su_kien.NgayBatDau,{$thoiGianBD})<=0 \r\n\t\t\t\t\t\tand DATEDIFF(su_kien.NgayKetThuc,{$thoiGianKT}) >=0\r\n\t\t\t\t\t\tAND su_kien.DaXoa = 0;"; $result = mysql_query($strSQL, ConnectDB::$mLink); if (!$result) { return null; } while ($row = mysql_fetch_array($result)) { $suKienDto = new SuKienDTO(); $suKienDto->MaSuKien = $row["MaSuKien"]; $suKienDto->MaGianHang = $row["MaGianHang"]; $suKienDto->TenSuKien = $row["TenSuKien"]; $suKienDto->HinhAnh = $row["HinhAnh"]; $suKienDto->NoiDungSuKien = $row["NoiDungSuKien"]; $suKienDto->NgayTao = $row["NgayTao"]; $suKienDto->NgayBatDau = $row["NgayBatDau"]; $suKienDto->NgayKetThuc = $row["NgayKetThuc"]; $suKienDto->NgayCapNhat = $row["NgayCapNhat"]; $suKienDto->NguoiCapNhat = $row["NguoiCapNhat"]; $suKienDto->NgayXoa = $row["NgayXoa"]; $suKienDto->NguoiXoa = $row["NguoiXoa"]; $suKienDto->DaXoa = $row["DaXoa"]; array_push($lstSuKien, $sanPhamDto); } ConnectDB::CloseConnection(); } catch (Exception $e) { $lstSuKien = null; } return $lstSuKien; }
/** * @param void * @return void * @description добавляет в класс экземпляр \PDO */ protected function setDb() { $this->db = ConnectDB::getInstance()->getPDO_instance(); }
<div class="form-group"> <label for="txtMatKhau" class="col-sm-2 control-label">Mật khẩu: </label> <div class="col-sm-5"> <input type="password" class="form-control" name="txtMatKhau" placeholder="Mật khẩu" value="<?php echo $row['MatKhau']; ?> "> </div> </div> <div class="form-group"> <label for="slPhanQuyen" class="col-sm-2 control-label">Phân quyền: </label> <div class="col-sm-5"> <select class="form-control" name="slPhanQuyen"> <?php require_once "../PHP/ConnectDB.php"; $conn = ConnectDB::connect(); $sqlDM = "SELECT MaPhanQuyen, MoTa FROM PhanQuyen"; $resutDM = mysqli_query($conn, $sqlDM); if ($resutDM->num_rows > 0) { while ($rowMD = $resutDM->fetch_assoc()) { if ($row['MaPhanQuyen'] == $rowMD['MaPhanQuyen']) { echo "<option value='" . $rowMD['MaPhanQuyen'] . "' selected> " . $rowMD['MoTa'] . "</option>"; } else { echo "<option value='" . $rowMD['MaPhanQuyen'] . "'> " . $rowMD['MoTa'] . "</option>"; } } } ?> </select> </div> </div>
/** * Lấy bình luận theo mã bình luận * Edit Ngọc Hà 16/6/2011 * Edit by Thu Hà 20/6/2011: nếu không tồn tại thì trả về null */ public static function LayBinhLuanTheoMaBL($maBL) { $binhLuanDto = new BinhLuanDAO(); try { if (!ConnectDB::OpenConnection()) { return false; } $strSQL = "select * from binh_luan bl where bl.MaBL = {$maBL};"; $result = mysql_query($strSQL, ConnectDB::$mLink); if ($result == false || mysql_num_rows($result) != 1) { return null; } $row = mysql_fetch_array($result); $binhLuanDto->MaBL = $row["MaBL"]; $binhLuanDto->NoiDungBL = $row["NoiDungBL"]; $binhLuanDto->NguoiBL = $row["NguoiBL"]; $binhLuanDto->NgayBL = $row["NgayBL"]; $binhLuanDto->DaXoa = $row["DaXoa"]; $binhLuanDto->NgayXoa = $row["NgayXoa"]; $binhLuanDto->NguoiXoa = $row["NguoiXoa"]; $binhLuanDto->DoiTuongBL = $row["DoiTuongBL"]; ConnectDB::CloseConnection(); } catch (Exception $e) { $binhLuanDto = null; } return $binhLuanDto; }
public static function KiemTraDangNhap($tenTaiKhoan, $matKhau) { $res = false; try { if (!ConnectDB::OpenConnection()) { return false; } $strSQL = "select * from `nguoi_dung` where `UserName` = '{$tenTaiKhoan}' AND `MatKhau` = '{$matKhau}'"; //echo $strSQL; $result = mysql_query($strSQL, ConnectDB::$mLink); if (!$result || mysql_num_rows($result) <= 0) { $res = false; } if (mysql_num_rows($result) == 1) { $res = true; } ConnectDB::CloseConnection(); } catch (Exception $e) { $res = false; } return $res; }
<?php $type_id = $_POST['item']; require_once 'ConnectDB.php'; $db = new ConnectDB(); $get_food_name = $db->db_accessor("DISTINCT id, japanese", "Mlang", "type_id = '{$type_id}'"); $html = $get_food_name; header('Content-type: application/json'); //指定されたデータタイプに応じたヘッダーを出力する echo json_encode($html);
require_once 'ConnectDB.php'; ?> <li id="food-box-template" class="item-box"> <input type="hidden" name="foodBoxId"> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label for="exampleInputEmail1">料理の種類</label> <select name="kindBox" class="kind-box form-control"> <?php $db = new ConnectDB(); $get_type = $db->db_accessor("DISTINCT type_id, type", "Mlang", "id >= 1"); ?> <option>種類を選択してください</option> <?php $i = 0; foreach ($get_type as $key => $value) { ?> <option value="<?php echo $value['type_id']; ?> "> <?php echo $value['type'];
public static function TinhTongSotienTheoMaDDH($maDDH) { $sum = 0; try { if (!ConnectDB::OpenConnection()) { return false; } $strSql = "SELECT SUM(`ThanhTien`) as TongSoTien FROM `chi_tiet_dat_hang` WHERE `MaDDH` = {$maDDH};"; $result = mysql_query($strSql, ConnectDB::$mLink); if (!$result || mysql_num_rows($result) != 1) { return 0; } $row = mysql_fetch_array($result); $sum = $row["TongSoTien"]; ConnectDB::CloseConnection(); } catch (Exception $e) { $sum = 0; } return $sum; }
$dirs = explode("/", $dirs); $dir = "/"; foreach ($dirs as $value) { if ($value === "script") { continue; } if (strlen($value) !== 0) { $dir .= $value . "/"; } } require $dir . "vendor/autoload.php"; require "ConnectDB.php"; use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; $client = new Client(); $connection = new ConnectDB(); $conn = $connection->InitialDB(); $AppToken = ""; $handle = @fopen($dir . "script" . "/token/tokens.txt", "r"); if (!$handle) { echo "the token file is not existed."; exit; } else { while (!feof($handle)) { $temp = fgets($handle, 4096); if ($temp != "") { $AppToken = $temp; } } fclose($handle); }
<title>メニュー表出力結果</title> <link rel="stylesheet" type="text/css" href="../css/reset.css"> <link rel="stylesheet" href="../css/result.css"> <link rel="stylesheet" href="//fonts.googleapis.com/earlyaccess/notosansjapanese.css"> </head> <body id="default_img_on" class="content-print food_theme"> <div class="wrapper"> <h1 class="store_name"><?php echo $_SESSION["storeName"]; ?> </h1> <div class="container"> <section class="inner-box"> <?php $db = new ConnectDB(); $foodCount = count($_SESSION["foodNameBox"]); // $_SESSIONの値を分割 $storeName = $_SESSION['storeName']; $langSelects = $_SESSION['langSelect']; $foodBoxId = $_SESSION['foodBoxId']; $tax = $_SESSION['tax']; $foodNameBoxes = $_SESSION['foodNameBox']; $foodOptions = $_SESSION['foodOption']; $prices = $_SESSION['price']; $foodImages = $_SESSION["upImgFile"]; $item = array(); for ($j = 0; $j < $foodCount; $j++) { $item[$j] = "<div class=\"item\">"; } // 画像を表示
public function __construct() { $this->conn = ConnectDB::getConn(); }
static function findOrderedCountries($continent, $region, $surface_min, $surface_max, $population_min, $population_max, $life_expectancy, $government_form, $city_count, $languages) { if ($continent == "") { $continent = '-1'; } if ($region == "") { $region = '%'; } if ($surface_min == "") { $surface_min = '-1'; } if ($surface_max == "") { $surface_max = '9000000000'; } if ($population_min == "") { $population_min = '-1'; } if ($population_max == "") { $population_max = '9000000000'; } if ($life_expectancy == "") { $life_expectancy = "-1"; } if ($government_form == "") { $government_form = '%'; } if ($city_count == "") { $city_count = '-1'; } //if(empty($languages)){echo 'ba aper';} $con = new ConnectDB(ProjectGlobals::$IPADDRESS, ProjectGlobals::$USER, ProjectGlobals::$PASSWORD, ProjectGlobals::$DATABASE); $result = $con->findOrderedCountries($continent, $region, $surface_min, $surface_max, $population_min, $population_max, $life_expectancy, $government_form, $city_count, $languages); $output = GenerateHTML::generateList($result, 'countryInfo.php?country'); return $output; }
/** * Ngọc Hà 12/6/2011 * Lấy danh mã gian hàng của sản phẩm * Enter description here ... */ public static function LayMaGianHangCuaSanPham($maSanPham) { $res = 0; ConnectDB::OpenConnection(); try { if (!ConnectDB::OpenConnection()) { return; } else { $strSQL = "\tSELECT lsp.MaGianHang\r\n\t\t\t\t\t\t\tFROM san_pham sp, loai_san_pham lsp\r\n\t\t\t\t\t\t\tWHERE sp.Ma = {$maSanPham} AND sp.MaLoaiSP = lsp.MaLoaiSP and sp.DaXoa = 0;"; $result = mysql_query($strSQL); $row = mysql_fetch_array($result); $res = $row["MaGianHang"]; if (!$result) { $res = 0; } } ConnectDB::CloseConnection(); } catch (Exception $e) { $res = 0; } return $res; }
public static function disconnect() { self::$conn->close(); self::$conn = null; }
function doLookup() { $connect = new ConnectDB(); $db = $connect->Product_Database(); // Product Classes $ProdClasses = $db->query("SELECT PRODUCT_CLASS_ID FROM PRODUCT_CLASSES_TABLE WITH(NOLOCK)"); $ProdClasses = $ProdClasses->fetchAllRows(); foreach ($ProdClasses as $k => $v) { $Lookup['PRODUCT_CLASS_ID'][] = $v['PRODUCT_CLASS_ID']; } // Brand Names $Brands = $db->query("SELECT DISTINCT(BRAND) AS BRANDS FROM INVENTORY_TABLE WITH(NOLOCK);"); $Brands = $Brands->fetchAllRows(); foreach ($Brands as $k => $v) { $Lookup['BRANDS'][] = $v['BRANDS']; } // Vendor IDs $Vendors = $db->query("SELECT VENDOR_ITEM_ID AS VENDORS FROM VENDOR_TABLE WITH(NOLOCK);"); $Vendors = $Vendors->fetchAllRows(); foreach ($Vendors as $k => $v) { $Lookup['VENDORS'][] = $v['VENDORS']; } // Destroy actual lookups (Everything is in a different array) unset($Vendors); unset($Brands); unset($ProdClasses); return $Lookup; }
public function excluir() { $id = $_GET['id']; try { ConnectDB::open(); $necessidadeEspecialDAO = new NecessidadeEspecialDAO(); $necessidadeEspecial = $necessidadeEspecialDAO->load($id); $necessidadeEspecialDAO->excluir($necessidadeEspecial); ConnectDB::close(); header('location: index.php?c=NecessidadeEspecialController&m=index'); } catch (PDOException $e) { echo $e->getMessage(); ConnectDB::close(); } }
/** * Lấy DS Chi Tiết Sự Kiện Theo Mã Sản Phẩm */ public static function LayDSChiTietSuKien_TheoMaSP($maSanPham) { $dsSuKien = array(); try { if (!ConnectDB::OpenConnection()) { return false; } $strSQL = "SELECT * FROM chi_tiet_su_kien WHERE Ma = {$maSanPham};"; $result = mysql_query($strSQL, ConnectDB::$mLink); if ($result == false) { return null; } while ($row = mysql_fetch_array($result)) { $chiTietSuKienDto = new ChiTietSuKienDTO(); $chiTietSuKienDto->MaSuKien = $row["MaSuKien"]; $chiTietSuKienDto->Ma = $row["Ma"]; $chiTietSuKienDto->PhanTram_GiaGiam = $row["PhanTramGiamGia"]; $chiTietSuKienDto->QuaTang = $row["QuaTang"]; array_push($dsSuKien, $chiTietSuKienDto); } ConnectDB::CloseConnection(); } catch (Exception $e) { $dsSuKien = null; } return $dsSuKien; }
$result = mysqli_query($conn, $sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo "<tr>"; echo "<td>" . $row['ID'] . "</td>"; echo "<th>" . $row['TieuDe'] . "</th>"; echo "<td>" . $row['NoiDung'] . "</td>"; echo "<td>" . $row['TenDN'] . "</td>"; echo "<td>" . $row['KiemDuyet'] . "</td>"; echo "<td>" . $row['NgayBinhLuan'] . "</td>"; echo "<td>\n\t\t\t\t\t\t\t<a href='BinhLuan_Doc.php?ID=" . $row['ID'] . "'><input type='button' value='Xem' class='btn btn-default'/></a>\n\t\t\t\t\t\t\t<a href='BinhLuan_Sua.php?ID=" . $row['ID'] . "'><input type='button' value='Sửa' class='btn btn-success'/></a>\n\t\t\t\t\t\t\t<a href='BinhLuan_Xoa.php?ID=" . $row['ID'] . "'> <input type='button' value='Xóa' class='btn btn-danger'/> </a>"; echo "</td>"; echo "</tr>"; } } ConnectDB::disconnect(); ?> </table> <?php //bắt đầu phân trang $page_cr = $start / $row_per_page + 1; //echo "<h4><span class='bg-primary'>". $page_cr."</span></h4>"; for ($i = 1; $i <= $page; $i++) { if ($page_cr != $i) { echo "<a href='QLBinhLuan.php?start=" . $row_per_page * ($i - 1) . "'><button type='button' class='btn btn-success'>" . $i . "</button></a>"; } else { echo "<button type='button' class='btn btn-warning'>" . $i . "</button>"; } } ?> </div>
/** * Xóa gian hàng * Edit by Thu Hà 20/11/2011 */ public static function XoaGianHang($maGianHang, $maNguoiDung) { $result = true; try { if (!ConnectDB::OpenConnection()) { return FALSE; } $strSQL = "\tUPDATE `gian_hang` \r\n\t\t\t\t\t\tSET `DaXoa` = 1, `NguoiXoa` = {$maNguoiDung}, `NgayXoa` = now()\r\n\t\t\t\t\t\tWHERE `MaGianHang` = {$maGianHang};"; $result = mysql_query($strSQL, ConnectDB::$mLink); ConnectDB::CloseConnection(); } catch (Exception $e) { $result = FALSE; } return $result; }