• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Mysql类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Mysql的典型用法代码示例。如果您正苦于以下问题:PHP Mysql类的具体用法?PHP Mysql怎么用?PHP Mysql使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Mysql类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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.";
         }
     }
 }
开发者ID:bridgegade,项目名称:TheGallery,代码行数:32,代码来源:Membership.php


示例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>
					';
        }
    }
}
开发者ID:TheRedJackal,项目名称:tippchampion,代码行数:29,代码来源:tip.php


示例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;
 }
开发者ID:dfg510dfg,项目名称:fvv,代码行数:34,代码来源:DAODirectorio.php


示例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;
 }
开发者ID:AyanUR,项目名称:WebApplication,代码行数:7,代码来源:ProductDAO.php


示例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');
     }
 }
开发者ID:phpwebset,项目名称:PHP-ChatRoom,代码行数:29,代码来源:LoginController.php


示例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>
				 ';
        }
    }
}
开发者ID:TheRedJackal,项目名称:tippchampion,代码行数:28,代码来源:profile.php


示例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;
 }
开发者ID:xuyintao,项目名称:thindev,代码行数:28,代码来源:Project.class.php


示例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>';
    }
}
开发者ID:TheRedJackal,项目名称:tippchampion,代码行数:25,代码来源:messages.php


示例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;
 }
开发者ID:xuyintao,项目名称:thindev,代码行数:9,代码来源:Developer.class.php


示例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());
 }
开发者ID:Eugen1985,项目名称:stalker_portal,代码行数:14,代码来源:ajaxresponse.class.php


示例11: createUser

 function createUser($un, $pwd)
 {
     $mysql = new Mysql();
     $createCredentials = $mysql->createUsernameandPass($un, md5($pwd));
     if ($createCredentials) {
         header("location: login.php");
     } else {
         return 1;
     }
 }
开发者ID:Captianrock,项目名称:android_PV,代码行数:10,代码来源:memberShip.php


示例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;
 }
开发者ID:xuyintao,项目名称:thindev,代码行数:10,代码来源:Memo.class.php


示例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();
 }
开发者ID:ekandreas,项目名称:docker-laravel,代码行数:10,代码来源:Helpers.php


示例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!";
     }
 }
开发者ID:nielssi,项目名称:BeachExplorer,代码行数:11,代码来源:Membership.php


示例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;
 }
开发者ID:AyanUR,项目名称:WebApplication,代码行数:12,代码来源:ClientDAO.php


示例16: printCountrySelect

function printCountrySelect()
{
    global $mysql;
    $MySQLConnection = new Mysql($mysql['host'], $mysql['port'], $mysql['user'], $mysql['password'], $mysql['database']);
    $MySQLConnection->connect();
    $result = $MySQLConnection->getQuery('SELECT * FROM countries;');
    echo '<select id="userCountry" name="userCountry"><option value="">---NO COUNTRY SELECTED---</option>';
    while ($row = mysqli_fetch_assoc($result)) {
        echo '<option value="' . $row["iso3166"] . '">' . $row["countryName"] . '</option>';
    }
    echo '</select>';
}
开发者ID:TheRedJackal,项目名称:tippchampion,代码行数:12,代码来源:registerform.php


示例17: __construct

 function __construct($name = '')
 {
     static $db;
     if (!is_object($db)) {
         $db = new Mysql();
     }
     if ($name) {
         $this->tablename = $name;
     } else {
         $this->tablename = MODEL_NAME;
     }
     $this->db = $db->t($this->tablename);
 }
开发者ID:xy113,项目名称:XiangBaLaoServer,代码行数:13,代码来源:class.Model.php


示例18: mantenimientoPopup

 public static function mantenimientoPopup(EntidadPopup $objPopupEntidad, array $param)
 {
     $query = NULL;
     $error = NULL;
     $objcons = new Mysql();
     try {
         $query = "CALL SP_MNT_POPUP('" . $param[0] . "',\n                                           '" . $objPopupEntidad->getIdpopup() . "',\n                                           '" . $objPopupEntidad->getNom() . "',    \n                                           '" . $objPopupEntidad->getImg() . "',    \n                                           '" . $objPopupEntidad->getAncho() . "',    \n                                           '" . $objPopupEntidad->getAlto() . "',        \n                                           '" . $objPopupEntidad->getResizable() . "',\n                                           '" . $objPopupEntidad->getPosition() . "', \n                                           '" . $objPopupEntidad->getEnlace() . "',\n                                           '" . $objPopupEntidad->getUrl() . "',\n                                           '" . $objPopupEntidad->getAbrir() . "',    \n                                           '" . $objPopupEntidad->getSwactivo() . "');";
         $rs = $objcons->ejecutar($query);
         $error = 1;
     } catch (PDOException $exc) {
         $error = 0;
     }
     return $error;
 }
开发者ID:dfg510dfg,项目名称:fvv,代码行数:14,代码来源:DAOPopup.php


示例19: mantenimientoServicio

 public static function mantenimientoServicio(EntidadServicio $objServicio, array $param)
 {
     $query = NULL;
     $error = NULL;
     $objMysql = new Mysql();
     try {
         $query = "CALL sp_mnt_servicio('" . $param[0] . "',\n                                           '" . $objServicio->getIdservicio() . "',\n                                           '" . $objServicio->getDescripcion() . "',\n                                           '" . $objServicio->getFoto() . "',    \n                                           '" . $objServicio->getFotochico() . "',        \n                                           '" . $objServicio->getEliminado() . "',\n                                           '" . $objServicio->getUrl() . "');";
         $rs = $objMysql->ejecutar($query);
         $error = 1;
     } catch (PDOException $exc) {
         $error = 0;
     }
     return $error;
 }
开发者ID:dfg510dfg,项目名称:fvv,代码行数:14,代码来源:DAOServicio.php


示例20: mantenimientoBanner

 public static function mantenimientoBanner(EntidadBannerInterior $objBannerEntidad, array $param)
 {
     $query = NULL;
     $error = NULL;
     $objMysql = new Mysql();
     try {
         $query = "CALL sp_mnt_bannerinterno('" . $param[0] . "',\n                                           '" . $objBannerEntidad->getIdbannerinterior() . "',\n                                           '" . $objBannerEntidad->getDescripcion() . "',\n                                           '" . $objBannerEntidad->getFoto() . "',    \n                                           '" . $objBannerEntidad->getFotochico() . "',        \n                                           '" . $objBannerEntidad->getEliminado() . "',\n                                           '" . $objBannerEntidad->getUrl() . "');";
         $rs = $objMysql->ejecutar($query);
         $error = 1;
     } catch (PDOException $exc) {
         $error = 0;
     }
     return $error;
 }
开发者ID:dfg510dfg,项目名称:fvv,代码行数:14,代码来源:DAOBannerInterno.php



注:本文中的Mysql类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP MysqliDb类代码示例发布时间:2022-05-23
下一篇:
PHP My_Model类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap