本文整理汇总了PHP中SafeMySQL::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP SafeMySQL::getInstance方法的具体用法?PHP SafeMySQL::getInstance怎么用?PHP SafeMySQL::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SafeMySQL
的用法示例。
在下文中一共展示了SafeMySQL::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCountryDefault
public static function getCountryDefault($countryID)
{
if (!$countryID) {
return false;
}
$sql = "SELECT *\n FROM `taxes`\n WHERE `country_id` = ?s\n AND `state_code` IS NULL";
$db = self::$_msql = SafeMySQL::getInstance();
$result = $db->getRow($sql, $countryID);
if ($result) {
$tax = new Tax();
$tax->fillFromArray($result);
return $tax;
}
return false;
}
示例2: __construct
public function __construct()
{
if (!self::$db) {
self::$db = SafeMySQL::getInstance();
}
parent::__construct();
}
示例3: beforeSave
public function beforeSave()
{
// make sure there isn't already a record with the same country and state code
$db = self::$_msql = SafeMySQL::getInstance();
$sql = "SELECT tax_id\n FROM `taxes`\n WHERE `country_id` = ?s";
if ($this->state_code) {
$sql .= " and state_code = ?s";
} else {
$sql .= " and state_code is NULL";
}
if ($this->tax_id) {
$sql .= " and tax_id = ?i";
if ($this->state_code) {
$result = $db->getOne($sql, $this->country_id, $this->state_code, $this->tax_id);
} else {
$result = $db->getOne($sql, $this->country_id, $this->tax_id);
}
} else {
if ($this->state_code) {
$result = $db->getOne($sql, $this->country_id, $this->state_code);
} else {
$result = $db->getOne($sql, $this->country_id);
}
}
if ($result) {
return false;
} else {
return TRUE;
}
}
示例4: firePixelPb
public static function firePixelPb($model)
{
$db = SafeMySQL::getInstance();
if (!$model instanceof Order) {
$model = Order::model()->findByPk($model);
}
if (!$model->order_id) {
return false;
}
// NOTE: temp. If a payment bank in array - we don't need to fire pixel
if ($model->payment && is_object($model->payment) && $model->payment->num2 && in_array($model->payment->num2, self::$_bannedBins) && in_array($model->campaign_id, self::$_bannedCampaigns)) {
return false;
}
$fire = false;
if ($model->aff_id) {
$sql = 'SELECT * FROM `pixel_rates` WHERE `campaign_id` = ?i AND `method_id` = ?i AND `aff_id` = ?i';
$result = $db->query($sql, $model->campaign_id, $model->payment->method_id, $model->aff_id);
$count_rows = $result->num_rows;
} else {
$count_rows = 0;
}
if (!$model->aff_id || !$count_rows) {
$sql = 'SELECT * FROM `pixel_rates` WHERE `campaign_id` = ?i AND `method_id` = ?i AND `aff_id` IS NULL';
$result = $db->query($sql, $model->campaign_id, $model->payment->method_id);
if (!$result->num_rows) {
$fire = true;
} else {
$fire_result = $db->fetch($result);
if ($fire_result['rate']) {
$fire = true;
}
if ($model->aff_id) {
$r = $fire_result['rate'] == 0 ? 0 : 1;
$sql = 'INSERT IGNORE INTO `pixel_rates` (`campaign_id`, `method_id`, `aff_id`, `rate`, `total_fired`, `total_orders`)
SELECT `campaign_id`, `method_id`, ?i, `rate`, ' . $r . ', 1
FROM `pixel_rates` WHERE `campaign_id` = ?i AND `method_id` = ?i AND `aff_id` IS NULL';
$db->query($sql, $model->aff_id, $model->campaign_id, $model->payment->method_id);
}
}
} else {
$fire_result = $db->fetch($result);
if ($fire_result['rate'] != 0 && ($fire_result['total_orders'] == 0 || 100 * $fire_result['total_fired'] / ($fire_result['total_orders'] + 1) < $fire_result['rate'])) {
$sql = 'UPDATE `pixel_rates` SET `total_fired` = `total_fired` + 1, `total_orders` = `total_orders` + 1 WHERE `campaign_id` = ?i AND `method_id` = ?s AND `aff_id` = ?i';
$db->query($sql, $model->campaign_id, $model->payment->method_id, $model->aff_id);
$fire = true;
} else {
$sql = 'UPDATE `pixel_rates` SET `total_orders` = `total_orders` + 1 WHERE `campaign_id` = ?i AND `method_id` = ?s AND `aff_id` = ?i';
$db->query($sql, $model->campaign_id, $model->payment->method_id, $model->aff_id);
}
}
if ($fire) {
$sql = 'UPDATE `orders` SET `pixel_fired` = 1 WHERE `order_id` = ?i';
$db->query($sql, $model->order_id);
exec('/usr/bin/php-cli /home/pinnacle/public_html/lj3/nws/pixels_pb.php ' . $model->order_id . ' > /dev/null 2>&1 &');
}
}
示例5: getAttachedByCampaign
public static function getAttachedByCampaign($campaign_id, $auto = true)
{
$db = SafeMySQL::getInstance();
$sql = "SELECT ca.`campattach_id`,\n\t\t\t\t\t\tca.`campaign_id`,\n ca.`campaign_attach_id`\n\t\t FROM `campaigns_attach` as ca\n WHERE ca.`campaign_id` = ?i";
if ($auto) {
$sql .= " and ca.`auto_attach` = 1";
}
$sql .= " ORDER BY ca.`campattach_id` ASC";
return $db->getAll($sql, $campaign_id);
}
示例6: fillFromDatabase
private static function fillFromDatabase()
{
$cacheID = "all_currencies";
self::$_allCurrencies = AF::cache()->get($cacheID);
if (!self::$_allCurrencies) {
$db = self::$_msql = SafeMySQL::getInstance();
$sql = "SELECT * FROM `currency`";
self::$_allCurrencies = $db->getInd('currency_id', $sql);
AF::cache()->set($cacheID, self::$_allCurrencies);
}
}
示例7: getResultsByCustomerId
public function getResultsByCustomerId($id, $cc = true)
{
if (!$id) {
return array();
}
$db = self::$_msql = SafeMySQL::getInstance();
$sql = "SELECT\n\t\t\tp.`payment_id`,\n\t\t\tp.`customer_id`,\n\t\t\tp.`method_id`,\n\t\t\tp.`num1`,\n\t\t\tp.`num2`,\n\t\t\tp.`num3`,\n\t\t\tp.`num4`,\n\t\t\tp.`txt1`,\n\t\t\tp.`txt2`,\n\t\t\tp.`txt3`,\n\t\t\tp.`txt4`";
$sql .= $cc ? " , p.`note1`" : '';
$sql .= "FROM `payments` as p\n\t\t\tWHERE p.`customer_id`=?i";
$sqlParse = $db->parse($sql, $id);
return $this->getSqlParse($sqlParse);
}
示例8: getDoubleShippingSKUArray
public static function getDoubleShippingSKUArray($campaignArray, $campaignID)
{
self::$DoubleShippingSKUArray = array();
if (!$campaignArray) {
return array();
}
$db = SafeMySQL::getInstance();
$sql = "SELECT cp.`campaign_id`\n FROM `products` as p\n JOIN `campaigns_products` as cp ON p.`product_id` = cp.`product_id`\n WHERE cp.`campaign_id` IN (?a)\n AND p.`product_shipping_sku` != ''";
$result = $db->getAll($sql, $campaignArray);
$resultArray = array();
foreach ($result as $item) {
$resultArray[] = $item['campaign_id'];
}
self::$DoubleShippingSKUArray = in_array($campaignID, $resultArray) ? $resultArray : array();
}
示例9: getResultsById
public function getResultsById($id, $ps = null)
{
if (!$id) {
return array();
}
$db = self::$_msql = SafeMySQL::getInstance();
$sql = "SELECT\n\t\t\t\tpm.`profile_id`,\n\t\t\t\tpm.`method_id`,\n\t\t\t\tm.`method_name`,\n\t\t\t\tm.`method_ref`,\n\t\t\t\tpm.`load_balance`,\n\t\t\t\tg.`system_code`\n FROM `profiles_methods` as pm\n\t\t\t JOIN `methods` as m on m.`method_id` = pm.`method_id`\n\t\t\t JOIN `profiles_gateways` as pg on pg.`profile_id` = pm.`profile_id` and pg.`method_id` = pm.`method_id`\n\t\t\t JOIN `gateways` as g on g.`gateway_id` = pg.`gateway_id`\n WHERE pm.`profile_id` = ?i";
if ($ps && strlen($ps)) {
$sql .= " AND g.`system_code` = ?s";
$sqlParse = $db->parse($sql, $id, $ps);
} else {
$sqlParse = $db->parse($sql, $id);
}
return $this->getSqlParse($sqlParse);
}
示例10: privilegeAction
function privilegeAction()
{
$model = new User();
$model->allFIelds = true;
$id = AF::get($this->params, 'id', 0);
if (!$id) {
throw new AFHttpException(0, 'no_id');
}
if (!$model->setByID($id)) {
throw new AFHttpException(0, 'incorrect_id');
}
$access = new Access();
$access->fillFromUser($model);
$userAccess = $access->getUserUpdateAccess();
ksort($userAccess);
if (isset($_POST['ajax'])) {
$newAcces = AF::get($_POST, 'array');
if ($newAcces) {
$access->setUserAccess($newAcces);
// hack to get the uesrs_access table to update instead of insert
$msql = SafeMySQL::getInstance();
$sql = "SELECT * FROM ?n WHERE user_id = ?i";
$result = $msql->getRow($sql, $access->tableName(), $access->user_id);
if (!empty($result)) {
$access->setIsNewRecord(0);
}
if ($access->save()) {
$model->user_id_updated = $this->user->user_id;
$model->updated = 'NOW():sql';
$model->IsNewRecord = false;
$model->save();
Message::echoJsonSuccess(__('user_access_updated'));
} else {
Message::echoJsonError(__('user_access_not_updated'));
}
} else {
Message::echoJsonError(__('user_access_not_updated'));
}
}
Assets::js('jquery.form');
$this->addToPageTitle('User privilege');
$this->render('privilege', array('userAccess' => $userAccess, 'model' => $model));
}
示例11: updateSites
public static function updateSites($campaignID)
{
$modelCampaign = Campaign::model()->with('domain')->cache()->findByPk($campaignID);
if (!$modelCampaign) {
return false;
}
$db = SafeMySQL::getInstance();
$sql = "SELECT c.`url`,\n c.`campaign_id`,\n c.`country_id`,\n c.`currency_id`\n FROM `campaigns` as c\n WHERE c.`domain_id` = ?i";
$campaigns = $db->getAll($sql, $modelCampaign->domain_id);
$rArray = array();
$cIDs = array();
foreach ($campaigns as $campaign) {
$cIDs[] = $campaign['campaign_id'];
$rArray[$campaign['campaign_id']] = array('main' => array('path' => $campaign['url'], 'campaign_id' => $campaign['campaign_id'], 'country_id' => $campaign['country_id'], 'currency_id' => $campaign['currency_id']), 'products' => array(), 'custom_fields' => array());
$sql = "SELECT `name`, `value`\n FROM `site_variables`\n WHERE (`domain_id`=?i AND`campaign_id`=?i)\n OR (`domain_id`=?i AND `campaign_id` IS NULL)\n OR (`domain_id` IS NULL AND `campaign_id` IS NULL)";
$customFields = $db->getAll($sql, $modelCampaign->domain_id, $campaign['campaign_id'], $modelCampaign->domain_id);
if ($customFields) {
foreach ($customFields as $field) {
$rArray[$campaign['campaign_id']]['custom_fields'][$field['name']] = $field['value'];
}
}
}
$sql = "SELECT p.`product_id`,\n p.`prodcat_id`,\n p.`product_name`,\n p.`product_price`,\n p.`product_weight`,\n p.`product_next_id`,\n p.`subscription_days`,\n cp.`campaign_id`\n FROM `products` as p\n JOIN `campaigns_products` as cp USING (`product_id`)\n WHERE cp.`campaign_id` IN (?a)\n AND cp.`enabled` = 1\n AND cp.`upsell_id` IS NULL";
$products = $db->getAll($sql, $cIDs);
if ($products) {
foreach ($products as $product) {
$campaignID = $product['campaign_id'];
unset($product['campaign_id']);
array_push($rArray[$campaignID]['products'], $product);
}
}
$siteApi = new SiteApi();
if (!$siteApi->createFile(json_encode($rArray))) {
//save an error to the log file
//..
return false;
}
$siteApi->domain = $modelCampaign->domain->url;
$siteApi->update();
}
示例12: long2ip
echo long2ip(2130706433);
die;
//time
$mtime = explode(" ", microtime());
$Smtime = $mtime[1] + $mtime[0];
$start_memory_usage = memory_get_usage();
//timeend---
/**
* User: Anton Antonov
* Date: 6/6/14
* Time: 7:47 AM
*/
@(include_once 'settings/autoload.php');
$productArray['subscription_days'] = 2;
$db = SafeMySQL::getInstance();
$result = array();
$result['status'] = 'upsell';
//$result['discount_next'] = 0;
//$result['created'] = date("Y-m-d H:i:s");
$result['amount_product'] = 11.2;
$result['amount_shipping'] = 0;
$result['amount_refunded'] = 0;
$result['payment_total'] = 0;
//$productArray['product_price'];
$result['pixel_fired'] = 0;
//$result['product_id'] = 111;
$result['shipping_id'] = 111;
//$result['rma_code'] = 'NULL:sql';
$result['recurring'] = $productArray['subscription_days'] ? 0 : 'NULL:sql';
$result['billing_cycle'] = 0;
示例13: removeAllByCM
public static function removeAllByCM($campaignID, $methodID)
{
$msql = SafeMySQL::getInstance();
$sql = "DELETE FROM `pixel_rates`\n WHERE `campaign_id` = ?i\n AND `method_id`= ?i";
$msql->query($sql, $campaignID, $methodID);
}
示例14: getAttemptNumberByOrderID
public static function getAttemptNumberByOrderID($orderID)
{
$msql = SafeMySQL::getInstance();
$sql = "SELECT `attempt_number` FROM `attempts` WHERE `order_id`=?i ORDER BY `attempt_number` DESC LIMIT 1";
$result = $msql->getRow($sql, $orderID);
return isset($result['attempt_number']) && $result['attempt_number'] ? $result['attempt_number'] + 1 : 1;
}
示例15: getPixelratesAffids
public static function getPixelratesAffids($campaignID, $methodID)
{
$msql = SafeMySQL::getInstance();
$sql = "SELECT a.`aff_id`, a.`aff_name`\n FROM `affiliates` as a\n LEFT JOIN `pixel_rates` as pr ON a.`aff_id`=pr.`aff_id` AND pr.`method_id`=?i AND pr.`campaign_id`=?i\n WHERE pr.`pixel_rate_id` IS NULL";
return $msql->getAll($sql, (int) $methodID, (int) $campaignID);
}