本文整理汇总了PHP中MYSQL类的典型用法代码示例。如果您正苦于以下问题:PHP MYSQL类的具体用法?PHP MYSQL怎么用?PHP MYSQL使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MYSQL类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SiteCreator_css
function SiteCreator_css(&$smarty, $form = false)
{
$mysql = new MYSQL($smarty);
$tabela = $smarty->cfg['prefix'] . 'bilder_site';
$mysql->SqlSelect("SELECT ID_SITE FROM {$tabela} WHERE site_dominio = '{$form['site_dominio']}'", __FILE__, __LINE__);
if (mysql_affected_rows() > 0) {
return $smarty->getFinishError('sitecreator_erro_01', array("", " - " . htmlspecialchars($this->form['site_dominio'])));
}
switch ($form['action']) {
case "selectcss":
$smarty->assign('ID_CSSCLASS', $form['ID_CSSCLASS']);
return $smarty->fetch($smarty->modulo_dir . "select_css.tpl");
break;
default:
$form['ID_MEMBER'] = $smarty->perfil['ID_MEMBER'];
$sql = $mysql->SqlInsert($tabela, $form);
$mysql->SqlSelect($sql, __FILE__, __LINE__);
$idde = mysql_insert_id();
$cam = './sites/' . $idde;
//$cam = './sites/21';
$site = new SiteCreator();
$site->CopyDefultSite($cam);
$site->createCfgfile($cam, array('ID_SITE' => $idde));
$site->CopyCss($form['ID_CSS'], $cam);
$site->createTemplates($cam, $form['site_pages']);
unset($_POST);
unset($_GET);
return $smarty->getFinish('sitecreator_sucesso_01');
break;
}
}
示例2: FORMAT
public static function FORMAT($S, $R, $P)
{
$I = array();
if ($P === false) {
$I[] = STR_REPLACE("/", "-", $R) . " 00:00:00";
$I[] = STR_REPLACE("/", "-", $R) . " 24:59:59";
$SET = 'HOUR';
} else {
$R = explode(" - ", $R);
$I[] = STR_REPLACE("/", "-", $R[0]);
$I[] = STR_REPLACE("/", "-", $R[1]);
$SET = 'DAY';
}
$I[] = $S['s_id'];
$Q = "SELECT MIN(t_checkout_created) AS `time`, AVG(t_checkout_price) AS `cost` FROM core_tickets_processed WHERE t_checkout_created >= ? AND t_checkout_created <= ? AND t_store = ? GROUP BY";
$CA = MYSQL::QUERY($Q . " {$SET}(t_checkout_created) ORDER BY t_checkout_created ASC", $I);
$CO = MYSQL::QUERY($Q . " t_checkout_created ORDER BY t_checkout_created ASC", $I);
$STRING = array();
$STRING[] = array('name' => 'Average Charge', 'data' => '');
$STRING[] = array('name' => 'Checkout Charges', 'data' => '');
foreach ($CA as $C) {
$T = Date_UTC($C['time']);
$STRING[0]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $T[3] . "," . $C['cost'];
}
foreach ($CO as $C) {
$T = Date_UTC($C['time']);
$STRING[1]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $T[3] . "," . $T[4] . "," . $C['cost'];
}
echo JSON_ENCODE($STRING);
}
示例3: FORMAT
public static function FORMAT($S, $R, $P)
{
$I = array($S['s_id']);
if ($P === false) {
$TI = "AND d_date = ? LIMIT 1";
$I[] = str_replace("/", "-", $R);
} else {
$R = explode(" - ", $R);
$TI = "AND d_date >= ? AND d_date <= ? ORDER BY d_date ASC";
$I[] = str_replace("/", "-", $R[0]);
$I[] = str_replace("/", "-", $R[1]);
}
$CT = MYSQL::QUERY("SELECT * FROM core_stores_daily_checkouts WHERE s_id = ? {$TI}", $I);
$STRING = array(array('name' => 'Sales', 'data' => ''));
if (!$P === false) {
foreach ($CT as $CL) {
$T = Date_UTC($CL['d_date']);
$Total = $CL['d_gross_nontaxable'] + $CL['d_gross_taxable'];
$STRING[0]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $Total;
}
} else {
$T = Date_UTC($CT['d_date']);
$Total = $CT['d_gross_nontaxable'] + $CT['d_gross_taxable'];
$STRING[0]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $Total;
}
if ($P === false) {
$STRING[0]['type'] = 'column';
}
echo JSON_ENCODE($STRING);
}
示例4: myRoles
function myRoles($username, $defult = array(ANONYMOUS_ID_ROLE => 'anonymous user'))
{
global $cfg;
if ($username >= 0) {
$mysql = new MYSQL($cfg);
$key = key($defult);
$valor = array_values($defult);
$sql = "\n\t\t\tSELECT r.ID_ROLE, r.name, p.permission, (SELECT permission FROM {permission} WHERE ID_ROLE = '{$key}')as `{$valor[0]}`\n\t\t\tFROM {users_roles} ur\n\t\t\tNATURAL JOIN {role} r\n\t\t\tLEFT JOIN {permission} p ON p.ID_ROLE = ur.ID_ROLE\n\t\t\tWHERE ID_USER = '{$username}' ORDER BY r.weight DESC\n\t\t\t";
$result = $mysql->SqlSelect($sql);
$perm['permission'] = array();
while ($row = mysql_fetch_assoc($result)) {
$perm['permission'] = explode(",", $row['permission']) + explode(",", $row[$valor[0]]);
$perm[$row['ID_ROLE']] = $row['name'];
}
return $perm;
}
}
示例5: stimulate
public function stimulate(&$hash)
{
$db = new MYSQL();
$db->connect(self::DB_HOST, self::DB_USER, self::DB_PASS, self::DB_DBNAME);
@mysql_query("SET NAMES 'UTF8'");
//must have a string parameter 'action'
LINB::checkArgs($hash, array('string' => array('action' => NULL)));
//handle the process
switch ($hash->action) {
case 'getlist':
return $db->query("select `key`,`value` from `tbl_test`");
case 'update':
//must have string parameters 'key' and 'value'
LINB::checkArgs($hash, array('string' => array('key' => NULL, 'value' => NULL)));
$db->update("tbl_test", array("key" => $hash->key, "value" => $hash->value), "`key`='" . $hash->key . "'");
return 'ok';
case 'delete':
//must have a string parameter 'key'
LINB::checkArgs($hash, array('string' => array('key' => NULL)));
$db->delete("tbl_test", "`key`='" . $hash->key . "'");
return 'ok';
case 'create':
//must have string parameters 'key' and 'value'
LINB::checkArgs($hash, array('string' => array('key' => NULL, 'value' => NULL)));
$db->insert("tbl_test", array("key" => $hash->key, "value" => $hash->value));
return 'ok';
}
}
示例6: LoadRules
function LoadRules($id, $acesso = 'ALL', &$smarty)
{
global $cfg;
switch ($acesso) {
case 'ONLY_GUEST':
return $id != 0 ? false : true;
break;
case 'NOT_GUEST':
return $id <= 0 ? false : true;
break;
case 'ALL':
return true;
break;
default:
$mysql = new MYSQL($smarty);
$result = $mysql->SqlSelect("SELECT r.name\n\t\t\t\t\t\t\t\t\t\t\tFROM {$cfg[db_prefix]}role r\n\t\t\t\t\t\t\t\t\t\t\tRIGHT JOIN {$cfg[db_prefix]}members_roles m ON r.ID_RULE = m.ID_RULE\n\t\t\t\t\t\t\t\t\t\t\tWHERE m.ID_MEMBER = '{$id}'\n\t\t\t\t\t\t\t\t\t\t\tORDER BY r.weight", __FILE__, __LINE__);
if (mysql_affected_rows() > 0) {
return $linha = mysql_fetch_assoc($result);
} else {
return false;
}
break;
}
}
示例7: FORMAT
public static function FORMAT($S, $R, $P)
{
$I = array($S['s_id']);
if ($P === false) {
$TI = "AND d_date = ? LIMIT 1";
$I[] = str_replace("/", "-", $R);
} else {
$R = explode(" - ", $R);
$TI = "AND d_date >= ? AND d_date <= ? ORDER BY d_date ASC";
$I[] = str_replace("/", "-", $R[0]);
$I[] = str_replace("/", "-", $R[1]);
}
$CT = MYSQL::QUERY("SELECT * FROM core_stores_daily_checkouts WHERE s_id = ? {$TI}", $I);
$STRING = array(array('name' => 'Cash', 'data' => ''), array('name' => 'Check', 'data' => ''), array('name' => 'American Express', 'data' => ''), array('name' => 'Discover', 'data' => ''), array('name' => 'Master Card', 'data' => ''), array('name' => 'Visa', 'data' => ''), array('name' => 'Debit', 'data' => ''));
if (!$P === false) {
foreach ($CT as $CL) {
$T = Date_UTC($CL['d_date']);
$STRING[0]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_cash'];
$STRING[1]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_check'];
$STRING[2]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_amex'];
$STRING[3]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_discover'];
$STRING[4]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_master'];
$STRING[5]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_visa'];
$STRING[6]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_debit'];
}
} else {
$T = Date_UTC($CT['d_date']);
$STRING[0]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_cash'];
$STRING[1]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_check'];
$STRING[2]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_amex'];
$STRING[3]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_discover'];
$STRING[4]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_master'];
$STRING[5]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_visa'];
$STRING[6]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_debit'];
}
if ($P === false) {
$STRING[0]['type'] = 'column';
$STRING[1]['type'] = 'column';
$STRING[2]['type'] = 'column';
$STRING[3]['type'] = 'column';
$STRING[4]['type'] = 'column';
$STRING[5]['type'] = 'column';
$STRING[6]['type'] = 'column';
}
echo JSON_ENCODE($STRING);
}
示例8: stimulate
public function stimulate(&$hash)
{
$db = new MYSQL();
$db->connect(self::DB_HOST, self::DB_USER, self::DB_PASS);
@mysql_query("SET NAMES 'UTF8'");
//must have a string parameter 'action'
LINB::checkArgs($hash, array('string' => array('action' => NULL)));
//handle the process
switch ($hash->action) {
case 'listdbs':
return $db->listdbs();
case 'listtables':
LINB::checkArgs($hash, array('string' => array('dbname' => NULL)));
return $db->listtables($hash->dbname);
case 'list':
LINB::checkArgs($hash, array('string' => array('dbname' => NULL, 'tablename' => NULL, 'page' => 1, 'count' => 20)));
$db->selectdb($hash->dbname);
$count = $db->query("select count(*) from " . $hash->tablename);
$table = $db->query("select * from " . $hash->tablename . " where 1 limit " . ($hash->page - 1) * 20 . ", " . $hash->count, true);
return array($count, $table);
}
}
示例9: array
<?php
require "../../../frame/engine.php";
ENGINE::START();
$user = USER::VERIFY(0, TRUE);
$CID = $_GET['cid'];
$CARD = $_GET['card'];
$TID = $_GET['tid'];
$CUSTOMER = MYSQL::QUERY('SELECT * FROM core_customers WHERE c_id = ? LIMIT 1', array($CID));
if (empty($CUSTOMER['c_card']) || $CUSTOMER['c_card'] == $CARD) {
if (empty($CUSTOMER['c_card'])) {
$CS = MYSQL::QUERY('SELECT c_id FROM core_customers WHERE c_card = ? LIMIT 1', array($CARD));
if (empty($CS)) {
echo "This customer has no card and this card is not in use. Please Enter their Primary email.<br/><br/><input type='email' placeholder='Customers Email Address..' style='width:280px;'><br/>\n\t\t\t<button style='cursor:pointer;width:287px;' onClick='AttachCard(\$(this)," . '"' . $CID . '"' . "," . '"' . $CARD . '"' . "," . '"' . $TID . '"' . "," . '"' . $user['store_info']['s_taxrate'] . '"' . ")'>Attach Card</button>";
} else {
echo "This card belongs to someone else...";
}
} else {
echo "Valid Card. 5% Off Applied.\n <script>AddDiscount('5','Membership Card','.ticket" . $TID . "','" . $user['store_info']['s_taxrate'] . "','" . $TID . "');</script>";
}
} else {
echo "This Customer has a different Card..";
}
示例10: switch
require "../../../frame/engine.php";
ENGINE::START();
$USER = USER::VERIFY(0, TRUE);
if (empty($_GET['sSearch'])) {
$S = $_GET['string'];
} else {
$S = $_GET['sSearch'];
}
$iDS = $_GET['iDisplayStart'];
$iDL = $_GET['iDisplayLength'];
$iSC = $_GET['iSortCol_0'];
$iSD = $_GET['sSortDir_0'];
switch ($iSC) {
case 0:
$SS = 'ORDER BY c_name ' . $iSD;
break;
case 1:
$SS = 'ORDER BY c_phone ' . $iSD;
break;
case 2:
$SS = '';
break;
}
$iTotal = MYSQL::QUERY('SELECT COUNT(c_id) AS `COUNT` FROM core_customers WHERE c_name LIKE ? OR c_phone LIKE ?', array('%' . $S . '%', '%' . $S . '%'));
$iQuery = MYSQL::QUERY("SELECT * FROM core_customers WHERE c_name LIKE ? OR c_phone LIKE ? {$SS} LIMIT {$iDS},{$iDL}", array('%' . $S . '%', '%' . $S . '%'), FALSE, TRUE);
$OUTPUT = array('sEcho' => $_GET['sEcho'], 'iTotalRecords' => $iTotal[0]['COUNT'], 'iTotalDisplayRecords' => $iTotal[0]['COUNT'], 'aaData');
foreach ($iQuery as $C) {
$OUTPUT['aaData'][] = array($C['c_name'], FORMAT::PHONE($C['c_phone']), '<button onClick="LoadCustomer(' . "'" . $C['c_id'] . "'" . ')">LOAD</button>');
}
echo JSON_ENCODE($OUTPUT);
示例11: array
<?php
require "../../../frame/engine.php";
ENGINE::START();
$user = USER::VERIFY(1);
$date = $_GET['date'];
$store = $_GET['store'];
$NOTES = MYSQL::QUERY("SELECT ctn.t_note FROM core_tickets_status cts JOIN core_tickets_note ctn ON cts.t_id = ctn.t_id AND ctn.t_note LIKE ? WHERE t_store = ?", array('%Walkedout Ticket%', $STORE, $SD, $ED));
示例12: array
$CHECKOUT = MYSQL::QUERY("SELECT * FROM core_checkout_sessions WHERE qb_id = ? LIMIT 1", array($_GET['chid']));
$ITEMS = EXPLODE('|', $CHECKOUT['items']);
$LIST = '';
$IT = 1;
$oldnontaxable = 0;
$nontaxable = 0;
$oldtaxable = 0;
$taxable = 0;
$oldtotaltax = 0;
$totaltax = 0;
foreach ($ITEMS as $I) {
if ($I != '') {
$I = EXPLODE('/', $I);
$LIST .= '|' . $I[0] . '/' . $_GET['item' . $IT];
$EX = EXPLODE('-', $I[0]);
if ($EX[0] == 'ti') {
MYSQL::QUERY('UPDATE core_tickets_processed SET t_checkout_created=?,t_checkout_price=? WHERE t_id=? LIMIT 1', array($_GET['date'], $_GET['item' . $IT], $EX[1]));
$nontaxable = $nontaxable + ($_GET['item' . $IT] - 0);
$oldnontaxable = $oldnontaxable + $I[1];
} else {
$taxable = $taxable + ($_GET['item' . $IT] - 0);
$totaltax = $totaltax + ($_GET['item' . $IT] - 0) / 100 * $user['store_info']['s_taxrate'];
$oldtaxable = $oldtaxable + $I[1];
$oldtotaltax = $I[1] / 100 * $user['store_info']['s_taxrate'];
}
}
$IT++;
}
MYSQL::QUERY('UPDATE core_checkout_sessions SET items=?,pm_1=?,pm_1_cost=?,pm_2=?,pm_2_cost=?,d_date=? WHERE qb_id=? LIMIT 1', array($LIST, $_GET['pm_1'], $_GET['pm_1_charge'], $_GET['pm_2'], $_GET['pm_2_charge'], $_GET['date'], $_GET['chid']));
TRACKING::CHECKOUTS($oldnontaxable, $oldtaxable, $oldtotaltax, $user, $CHECKOUT['pm_1'], $CHECKOUT['pm_1_cost'], $CHECKOUT['pm_2'], $CHECKOUT['pm_2_cost'], '-', $_GET['date']);
TRACKING::CHECKOUTS($nontaxable, $taxable, $totaltax, $user, $_GET['pm_1'], $_GET['pm_1_charge'], $_GET['pm_2'], $_GET['pm_2_charge'], '+', $_GET['date']);
示例13: mysql_escape_string
}
}
}
if ($i == 1) {
$comma = ' ';
} else {
$comma = ', ';
}
$added .= "{$name}<br/><br/>";
$query .= $comma . '("' . $man[1] . '", "' . $type . '", "' . mysql_escape_string($name) . '", "' . mysql_escape_string($img) . '", "' . mysql_escape_string($also) . '", "' . $date . '")';
$i++;
}
if ($query == 'INSERT IGNORE INTO device_models (m_manufacturer_id, m_type, m_name, m_link, m_known, m_date) VALUES') {
break;
}
MYSQL::QUERY($query);
$a++;
}
if ($type == 4) {
break;
}
$type++;
}
}
?>
<form method='post'>
<select name='manu'><?php
echo $options;
?>
</select><input type='submit' name='submit' value='submit'>
</form>
示例14: STR_REPLACE
}
$A['Q2'] = STR_REPLACE(array('+', '-', '=', ' '), '', $Q);
if ($A['Q1'] != '=') {
$A['Q3'] = 'quantity = quantity ' . $A['Q1'] . ' ?';
} else {
$A['Q3'] = 'quantity = ?';
}
$A['P1'] = SUBSTR($P, 0, 1);
if (IS_NUMERIC($A['P1'])) {
$A['P1'] = '=';
}
$A['P2'] = STR_REPLACE(array('+', '-', '=', ' '), '', $P);
if ($A['P1'] != '=') {
$A['P3'] = 'price = price ' . $A['P1'] . ' ?';
} else {
$A['P3'] = 'price = ?';
}
$A['M1'] = SUBSTR($M, 0, 1);
if (IS_NUMERIC($A['M1'])) {
$A['M1'] = '=';
}
$A['M2'] = STR_REPLACE(array('+', '-', '=', ' '), '', $M);
if ($A['M1'] != '=') {
$A['M3'] = 'minimum = minimum ' . $A['M1'] . ' ?';
} else {
$A['M3'] = 'minimum = ?';
}
$Q = 'INSERT INTO inventory_stock (store, item, quantity, minimum, price, modified) VALUES (?,?,?,?,?,?) ON DUPLICATE KEY UPDATE ' . $A['Q3'] . ', ' . $A['P3'] . ', ' . $A['M3'];
MYSQL::QUERY($Q, array($user['store'], $PID, $A['Q2'], $A['M2'], $A['P2'], DATE('Y-m-d H:i:s'), $A['Q2'], $A['P2'], $A['M2']));
$CHECK = MYSQL::QUERY('SELECT quantity,minimum,price FROM inventory_stock WHERE store = ? AND item = ? LIMIT 1', array($user['store'], $PID));
echo $CHECK['quantity'] . '|' . $CHECK['price'] . '|' . $CHECK['minimum'];
示例15: array
$TICKET = MYSQL::QUERY("SELECT * FROM core_tickets_status WHERE t_id = ? LIMIT 1", array($TID));
switch ($TICKET['t_status']) {
case 97:
$TBL = 'core_tickets_estimate';
$ST = 1;
break;
case 98:
$TBL = 'core_tickets_repair';
$ST = 2;
break;
case 99:
$TBL = 'core_tickets_checkout';
$ST = 3;
break;
}
$ROWS = MYSQL::QUERY("SHOW COLUMNS FROM {$TBL}");
$QUERY = "INSERT INTO {$TBL} SELECT ";
$I = 0;
foreach ($ROWS as $R) {
if ($I == 0) {
$QUERY .= $R['Field'];
} else {
$QUERY .= "," . $R['Field'];
}
$I++;
}
$QUERY .= " FROM core_tickets_walkout WHERE t_id = ? LIMIT 1";
MYSQL::QUERY($QUERY, array($TID));
MYSQL::QUERY("DELETE FROM core_tickets_walkout WHERE t_id = ? LIMIT 1", array($TID));
MYSQL::QUERY("UPDATE core_tickets_status SET t_status = ? WHERE t_id = ? LIMIT 1", array($ST, $TID));
USER::NOTE($TID, "Ticket Re-Opened", 2);