本文整理汇总了PHP中MySql类的典型用法代码示例。如果您正苦于以下问题:PHP MySql类的具体用法?PHP MySql怎么用?PHP MySql使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MySql类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Atualizar
private function Atualizar(Cliente $cliete)
{
$conexao = new MySql();
$objCliente = new Cliente();
//Seleciona endereço na base
$sql = "set @nome='{$cliete->getNome}; \r\n set @cpf='{$cliete->getCpf}';\r\n set @data_nascimento='{$cliete->getDataNasc}()';\r\n set @telefone='{$cliete->getTelefone}()';\r\n set @celular='{$cliete->getCelular}()';\r\n set @email='{$cliete->getEmail}()';\r\n set @cep='{$cliete->getCep}()';\r\n set @endereco='{$cliete->getEndereco}()'; \r\n set @numero='{$cliete->getNumero}()';\r\n set @complemento='{$cliete->getComplemento}()';\r\n set @bairro='{$cliete->getBairro}()';\r\n set @cidade='{$cliete->getCidade}()';\r\n set @uf='{$uf->getUf}()';\r\n call USP_MANTER_CLIENTES(@nome,@cpf,@data_nasc,\r\n @telefone,@celular,@email,@cep,@endereco,@numero,\r\n @complemento,@bairro,@cidade,@uf,NULL,NULL,0);";
$retorno = $conexao->execSP($sql);
}
示例2: exportContacts
public function exportContacts()
{
require_once dirname(__FILE__) . "/mysql.php";
$pDB = new MySql();
$pDB->Query("SELECT `phonebook`.`Name`, `phonebook`.`Phone` FROM `phonebook` ORDER BY `phonebook`.`Name` ASC");
header("Content-Disposition: attachment; filename=\"smsys_" . date("Y-m-d_His") . ".vcf");
header("Content-Type: application/force-download");
while ($arContact = $pDB->FetchAssoc()) {
echo "BEGIN:VCARD\nVERSION:2.1\nN:;" . $arContact['Name'] . ";;;\nFN:" . $arContact['Name'] . "\nTEL;CELL;PREF:" . $arContact['Phone'] . "\nEND:VCARD\n";
}
$pDB->Log("Export contacts list");
}
示例3: getIns
/**
* 供外界获取实例
* @return MySql
*/
public static function getIns()
{
if (self::$ins == false) {
self::$ins = new self();
}
return self::$ins;
}
示例4: getInstance
/**
* 静态方法,返回数据库连接实例
*/
public static function getInstance()
{
if (self::$instance == null) {
self::$instance = new MySql();
}
return self::$instance;
}
示例5: Get
static function Get($key = '')
{
if (count(self::$_settings) == 0) {
self::$_settings = MySql::Instance()->QuickArray("SELECT * FROM settings");
}
if (self::$_settings[$key] != null) {
return self::$_settings[$key];
}
return self::$_settings;
}
示例6: updateUnicode
function updateUnicode()
{
$db = new MySql(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DB);
$sql = "SELECT\r\n `id`,\r\n `character`\r\n FROM\r\n `tomoe_character`\r\n WHERE\r\n `unicode` = 0\r\n LIMIT 0,5000;";
$result = $db->query($sql);
$num_before = $db->num_rows;
if ($num_before > 0) {
$usc_4 = 0;
foreach ($result as $r) {
$usc_4 = utf8ToUnicode($r->character);
$sql = " UPDATE\r\n tomoe_character\r\n SET\r\n unicode = {$usc_4['0']}\r\n WHERE id = {$r->id};";
//echo $sql;
$db->update($sql);
}
echo "请刷新页面。" . time();
} else {
echo "Unicode字段更新完毕";
}
}
示例7: networkCoins
/** Get Api Key
* @param $login string
* @param $password string
* @param $coin string
* @return bool|mysqli_result
*/
public static function networkCoins($login, $password, $coin)
{
$link = MySql::connect();
$resultArray = null;
mysqli_query($link, "SET character_set_results = 'utf8'");
$query = sprintf("SELECT coins.%s as apikey FROM coins,users WHERE users.Email='%s' AND users.Password='%s'", mysqli_real_escape_string($link, trim($coin)), mysqli_real_escape_string($link, trim($login)), mysqli_real_escape_string($link, trim($password)));
$result = mysqli_query($link, $query);
$row = mysqli_fetch_array($result);
$result = $row['apikey'];
return $result;
}
示例8: getInstance
public static function getInstance()
{
switch (Option::DEFAULT_MYSQLCONN) {
case 'mysqli':
return MySqlii::getInstance();
break;
case 'mysql':
default:
return MySql::getInstance();
break;
}
}
示例9: getDbInstance
/**
* 获取Db实例
* @param null
*/
public function getDbInstance()
{
if (!is_null($this->_db)) {
return $this->_db;
}
if (class_exists('mysqli')) {
$this->_db = MySqlii::getInstance();
} else {
$this->_db = MySql::getInstance();
}
return $this->_db;
}
示例10: getInstance
public static function getInstance()
{
if (class_exists('mysqli', FALSE)) {
return MySqlii::getInstance();
} else {
if (class_exists('mysql', FALSE)) {
return MySql::getInstance();
} else {
emMsg('服务器空间PHP不支持MySql数据库');
}
}
}
示例11: asc_time_limit
function asc_time_limit($ip, $time_limit)
{
$DB = MySql::getInstance();
if ($time_limit <= 0) {
return;
}
$time_line = time() - $time_limit;
$sql = "SELECT ip FROM " . DB_PREFIX . "comment WHERE ip='{$ip}' AND date > {$time_line}";
$query = $DB->query($sql);
$num = $DB->num_rows($query);
if ($num) {
ascMsg("{$time_limit}秒内只能发表一次评论,评论发表失败");
}
}
示例12: getValue
public function getValue()
{
require "mysql_util.php";
if (isset($operandValue)) {
return $operandValue;
}
$mysqli = MySql::getConnection();
$questionID = trim($operandString, "[]");
$mysql_value = $mysqli->query("SELECT `Response` FROM Questions WHERE `ID` = '{$questionID}'");
if (!$mysql_value) {
throw new Exception("There was a MySQL error: {$mysqli->error}");
return false;
}
$mysql_value = mysqli_fetch_assoc($mysql_value);
return $mysql_value['Response'];
}
示例13: __construct
public function __construct()
{
if (is_null(self::$DbHandler)) {
if (class_exists('mysqli')) {
self::$DbHandler = MySqlii::getInstance();
} else {
self::$DbHandler = MySql::getInstance();
}
}
$this->tableName = DB_PREFIX . $this->tableName;
$this->fields = $this->getDbFields();
foreach ($this->fields as $key => $value) {
$this->SQLfields .= $this->parseKey($value) . ',';
}
$this->SQLfields = rtrim($this->SQLfields, ',');
#查询的全字段预处理
}
示例14: getSmallImg
function getSmallImg($gid)
{
$db = MySql::getInstance();
$sql = "SELECT excerpt FROM " . DB_PREFIX . "blog WHERE checked='y' and password='' and gid=" . $gid;
$query = $db->query($sql);
while ($row = $db->fetch_array($query)) {
preg_match_all("/<img([^>]+)src=\"([^>\"]+)\"?([^>]*)>/i", $row['excerpt'], $matches);
//从摘要找缩略图
if ($matches[2][1]) {
//$imgsrc=$matches[2][1]?$matches[2][1]:$matches[2][0];
$imgsrc = $matches[2][1];
} else {
$imgsrc = TEMPLATE_URL . "img/bgtest.png";
}
}
return $imgsrc;
}
示例15: canRemoveEntity
/**
* @test
*/
public function canRemoveEntity()
{
$expectedConditions = array('id' => 1);
$this->storage->expects($this->once())->method('deleteWhere')->with($expectedConditions)->will($this->returnValue(1));
$entity = $this->createEntity();
$entity->setId(1);
$this->repository->remove($entity);
$this->assertEquals(null, $entity->getId());
}