本文整理汇总了PHP中Mysql类的典型用法代码示例。如果您正苦于以下问题:PHP Mysql类的具体用法?PHP Mysql怎么用?PHP Mysql使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mysql类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attach_Image
function attach_Image($fileDirectory)
{
$Mysql = new Mysql();
$uploadCheck = 1;
$imageFileType = pathinfo($fileDirectory, PATHINFO_EXTENSION);
//checks if image
if (isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if ($check !== false) {
$uploadCheck = 1;
} else {
return "File is not an image.";
$uploadCheck = 0;
}
//check if image already exisits
if (file_exists($fileDirectory)) {
return "Sorry, file already exists.";
$uploadCheck = 0;
}
}
//check
if ($uploadCheck == 0) {
return "There was a problem uploading your file.";
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $fileDirectory)) {
$Mysql->attach_Image_To_Account("/userImages/" . basename($_FILES["fileToUpload"]["name"]));
return "The file " . basename($_FILES["fileToUpload"]["name"]) . " has been uploaded.";
} else {
return "Sorry, there was an error uploading your file.";
}
}
}
示例2: buildPage
function buildPage()
{
global $mysql;
$MySQLConnection = new Mysql($mysql['host'], $mysql['port'], $mysql['user'], $mysql['password'], $mysql['database']);
$MySQLConnection->connect();
if ($result = $MySQLConnection->getQuery('SELECT x.matchID AS matchID, x.matchDate AS matchDate, y.teamName AS matchHomeTeam, y.teamLogo AS matchHomeTeamLogo, z.teamName AS matchForeignTeam, z.teamLogo AS matchForeignTeamLogo FROM matches AS x JOIN teams AS y ON y.teamID = matchHomeTeam JOIN teams AS z ON z.teamID = matchForeignTeam;')) {
while ($row = mysqli_fetch_assoc($result)) {
$userTips = getUserTips($MySQLConnection, $row["matchID"]);
echo '
<div class="panel panel-default">
<form id="match_' . $row["matchID"] . '" method="POST">
<div class="panel-body">
<div class="panel-heading">' . $row["matchHomeTeam"] . ' vs. ' . $row["matchForeignTeam"] . '</div>
<div class="input-group">
<label>' . $row["matchHomeTeam"] . '</label>
<input type="number"min="0"value="' . $userTips["tipScoreHome"] . '" name="ScoreHome" id="ScoreHome" required/>
</div>
<div class="input-group">
<label>' . $row["matchForeignTeam"] . '</label>
<input type="number"min="0" value="' . $userTips["tipScoreForeign"] . '" name="ScoreForeign" id="ScoreForeign" required/>
<input type="button" value="Place Tip" onclick="placeTip(' . $row["matchID"] . ');"/>
</div>
</div>
</form>
</div>
';
}
}
}
示例3: mantenimientoDirectorio
public static function mantenimientoDirectorio(EntidadDirectorio $objDirectorioEntidad, array $param)
{
$query = NULL;
$query2 = NULL;
$error = NULL;
$objMysql = new Mysql();
$objMysql1 = new Mysql();
if ($param[0] == 'DEL') {
$query2 = "select count(*) as 'cantidad' from cms_directorio where idcontenedor='" . $objDirectorioEntidad->getIdDirectorio() . "'";
$res_verificar = $objMysql1->ejecutar($query2);
$reg = $res_verificar->fetch(PDO::FETCH_ASSOC);
if ($reg['cantidad'] != 0) {
$error = 2;
} else {
$objMysql = new Mysql();
try {
$query = "CALL sp_mnt_directorio('" . $param[0] . "','" . $objDirectorioEntidad->getIdDirectorio() . "','" . $objDirectorioEntidad->getNombre() . "','" . $objDirectorioEntidad->getNivel() . "','" . $objDirectorioEntidad->getPosicion() . "','" . $objDirectorioEntidad->getContenido() . "','" . $objDirectorioEntidad->getIdpagina() . "','" . $objDirectorioEntidad->getRuta() . "','" . $objDirectorioEntidad->getIdcontenedor() . "','" . $objDirectorioEntidad->getAbrir() . "','" . $objDirectorioEntidad->getMostrar() . "','" . $objDirectorioEntidad->getEliminado() . "');";
$rs = $objMysql->ejecutar($query);
$error = 1;
} catch (PDOException $exc) {
$error = 0;
}
}
} else {
try {
$query = "CALL sp_mnt_directorio('" . $param[0] . "','" . $objDirectorioEntidad->getIdDirectorio() . "','" . $objDirectorioEntidad->getNombre() . "','" . $objDirectorioEntidad->getNivel() . "','" . $objDirectorioEntidad->getPosicion() . "','" . $objDirectorioEntidad->getContenido() . "','" . $objDirectorioEntidad->getIdpagina() . "','" . $objDirectorioEntidad->getRuta() . "','" . $objDirectorioEntidad->getIdcontenedor() . "','" . $objDirectorioEntidad->getAbrir() . "','" . $objDirectorioEntidad->getMostrar() . "','" . $objDirectorioEntidad->getEliminado() . "');";
$rs = $objMysql->ejecutar($query);
$error = 1;
} catch (PDOException $exc) {
$error = 0;
}
}
return $error;
}
示例4: removeProduct
public static function removeProduct($barcode, $expiration)
{
$mysql = new Mysql();
$update = $mysql->update("delete from product where barcode='{$barcode}' and expiration='{$expiration}'");
$mysql->closeConnection();
return $update;
}
示例5: login
function login()
{
require 'Conn/Redirect.php';
$redirect = new Redirect();
if (isset($_POST["name"]) && isset($_POST["pwd"])) {
$name = $_POST["name"];
$pwd = md5($_POST["pwd"]);
require_once 'Conn/Mysql.php';
$mysql = new Mysql();
$mysql->query("select * from users where name ='{$name}';");
$row = $mysql->get_object();
if (isset($row)) {
if ($row->pwd == $pwd) {
session_start();
$_SESSION['user'] = $name;
$redirect->go('index.php');
} else {
$error = "密码错误!";
$redirect->go('index.php?page=login');
}
} else {
$error = "用户名不存在!";
$redirect->go('index.php?page=login');
}
} else {
$error = "用户名或密码不能为空!";
$redirect->go('index.php?page=login');
}
}
示例6: buildPage
function buildPage()
{
global $mysql;
$MySQLConnection = new Mysql($mysql['host'], $mysql['port'], $mysql['user'], $mysql['password'], $mysql['database']);
$MySQLConnection->connect();
if ($result = $MySQLConnection->getQuery('SELECT * FROM users JOIN countries ON userCountry = iso3166 WHERE userID = ' . $_GET["userID"] . ';')) {
while ($row = mysqli_fetch_assoc($result)) {
echo '
<div class="col-md-2">
<div class="panel panel-default">
<div class="panel-heading">' . $row["userLogin"] . '</div>
<div class="panel-body">
<div class="media">
<div class="media-left">
<a href="img/avatar/' . $row["userAvatar"] . '">
<img class="media-object" src="img/avatar/' . $row["userAvatar"] . '" />
</a>
</div>
</div>
<p><b>First Name: </b>' . $row["userFirstName"] . '</p>
<p><b>Last Name: </b>' . $row["userLastName"] . '</p>
</div>
</div>
</div>
';
}
}
}
示例7: getList
public function getList($search)
{
$mysql = new Mysql();
$PageSize = intval($search->PageSize);
$FirstRow = intval($search->PageIndex - 1) * $PageSize;
$sqlList = "select Subject,Url from project where (Status=6 or Status=7) and Type=" . intval($this->Type) . " order by Pv desc LIMIT {$FirstRow}, {$PageSize};";
$sqlCount = "select count(Id) from project where (Status=6 or Status=7) and Type=" . intval($this->Type);
$res = array();
if ($search->NeedCount) {
// 查找 count 和 数据
$totalCount = $mysql->getVar($sqlCount);
if (empty($totalCount)) {
$res["Success"] = true;
$res["Data"] = null;
$res["Count"] = 0;
} else {
$res["Success"] = true;
$res["Data"] = $mysql->getData($sqlList);
$res["Count"] = $totalCount;
}
} else {
// 只查找数据
$res["Success"] = true;
$res["Data"] = $mysql->getData($sqlList);
}
$mysql->closeDb();
return $res;
}
示例8: buildPage
function buildPage()
{
global $mysql;
$MySQLConnection = new Mysql($mysql['host'], $mysql['port'], $mysql['user'], $mysql['password'], $mysql['database']);
$MySQLConnection->connect();
if ($result = $MySQLConnection->getQuery('SELECT messageID, messageRecipient, messageSender, messageTime, messageSubject, messageBody, userLogin, userID FROM messages JOIN users ON messageSender = userID WHERE messageRecipient = ' . $_SESSION["userID"] . ' LIMIT 0,25;')) {
echo '
<div class="col-md-2">
';
while ($row = mysqli_fetch_object($result)) {
$messageJSON = (string) json_encode($row);
echo '
<div class="list-group">
<a href="#" onclick="displayMessage(\'' . $row->messageID . '\');"" class="list-group-item">
<p class="list-group-item-text">' . $row->messageTime . ' - ' . $row->userLogin . '</p>
<h4 class="list-group-item-heading">' . $row->messageSubject . '</h4>
</a>
</div>
';
}
echo '</div>';
} else {
echo '<script type="text/javascript">', 'printError(\'Error while getting your messages!\')', '</script>';
}
}
示例9: getUserByProjectId
public function getUserByProjectId($projectId)
{
$mysql = new Mysql();
$sql = "SELECT GROUP_CONCAT(DISTINCT result.UserId) as Ids ,GROUP_CONCAT(DISTINCT result.name) as Names FROM (SELECT d.UserId,u.Name FROM " . $mysql->dbpre . "developer" . $mysql->debug . " as d ," . $mysql->dbpre . "user" . $mysql->debug . " as u WHERE d.UserId=u.UserId and ProjectId=" . intval($projectId) . " ) as result";
//echo $sql;
$result = $mysql->getLine($sql);
$mysql->closeDb();
return $result;
}
示例10: setResponseData
/**
* Add main response fields.
*
* @param Mysql $query
*/
protected function setResponseData(Mysql $query)
{
$query_rows = clone $query;
$this->setResponse('total_items', $query_rows->nolimit()->nogroupby()->noorderby()->count()->get()->counter());
//$this->setResponse('total_items', $query_rows->nolimit()->noorderby()->get()->count());
$this->setResponse('cur_page', $this->cur_page);
$this->setResponse('selected_item', $this->selected_item);
$this->setResponse('data', $query->get()->all());
}
示例11: createUser
function createUser($un, $pwd)
{
$mysql = new Mysql();
$createCredentials = $mysql->createUsernameandPass($un, md5($pwd));
if ($createCredentials) {
header("location: login.php");
} else {
return 1;
}
}
示例12: getList
public function getList($projectId)
{
$mysql = new Mysql();
$sql = "SELECT m.*,u.Name FROM " . $mysql->dbpre . "memo" . $mysql->debug . " as m," . $mysql->dbpre . "user" . $mysql->debug . " as u WHERE m.UserId=u.UserId AND ProjectId=" . intval($projectId);
// var_dump( $sql );
// exit;
$result = $mysql->getData($sql);
$mysql->closeDb();
return $result;
}
示例13: kill
public static function kill()
{
$mysql_name = env('container') . '_mysql';
$mysql = new Mysql($mysql_name);
$mysql->kill();
$web_name = basename(self::getProjectDir());
$web_name .= '_web';
$web = new Web($web_name);
$web->kill();
}
示例14: validate_user
function validate_user($un, $pwd)
{
$mysql = new Mysql();
$ensure_credentials = $mysql->verify_Username_and_Pass($un, md5($pwd));
if ($ensure_credentials) {
$_SESSION['status'] = 'authorized';
header("location: index2.php");
} else {
return "Benutzername und Passwort nicht korrekt!";
}
}
示例15: getClient
public static function getClient($email, $password)
{
$mysql = new Mysql();
$response = $mysql->query("select * from client where email='{$email}' and password=PASSWORD('{$password}')");
$mysql->closeConnection();
if ($response == false) {
return false;
}
$response = mysql_fetch_assoc($response);
$client = new Client($response['name'], $response['surname'], $response['email'], $response['password']);
return $client;
}