本文整理汇总了PHP中ps_DB::setQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP ps_DB::setQuery方法的具体用法?PHP ps_DB::setQuery怎么用?PHP ps_DB::setQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ps_DB
的用法示例。
在下文中一共展示了ps_DB::setQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: count
function validate_add($d)
{
global $VM_LANG;
$db = new ps_DB();
if (!$d["currency_name"]) {
$GLOBALS['vmLogger']->err($VM_LANG->_('VM_CURRENCY_ERR_NAME'));
return False;
}
if (!$d["currency_code"]) {
$GLOBALS['vmLogger']->err($VM_LANG->_('VM_CURRENCY_ERR_CODE'));
return False;
}
if ($d["currency_name"]) {
$q = "SELECT count(*) as rowcnt from #__{vm}_currency where";
$q .= " currency_name='" . $d["currency_name"] . "'";
$db->setQuery($q);
$db->query();
$db->next_record();
if ($db->f("rowcnt") > 0) {
$GLOBALS['vmLogger']->err($VM_LANG->_('VM_CURRENCY_ERR_EXISTS'));
return False;
}
}
return True;
}
示例2: htmlentities
/**
* Function to calculate the price, apply discounts from the discount table
* and reformat the price
*
* @param int $product_id
* @param boolean $hide_tax Wether to show the text "(including X.X% tax)" or not
* @return string The formatted price
*/
function show_price($product_id, $hide_tax = false)
{
global $VM_LANG, $CURRENCY_DISPLAY, $vendor_mail;
$auth = $_SESSION['auth'];
$tpl = new $GLOBALS['VM_THEMECLASS']();
$product_name = htmlentities($this->get_field($product_id, 'product_name'), ENT_QUOTES);
$tpl->set('product_id', $product_id);
$tpl->set('product_name', $product_name);
$tpl->set('vendor_mail', $vendor_mail);
$discount_info = $base_price = array();
$text_including_tax = '';
if ($auth['show_prices']) {
// Get the DISCOUNT AMOUNT
$discount_info = $this->get_discount($product_id);
if (!$discount_info["is_percent"] && $discount_info["amount"] != 0) {
$discount_info["amount"] = $GLOBALS['CURRENCY']->convert($discount_info["amount"]);
}
// Get the Price according to the quantity in the Cart
$price_info = $this->get_price($product_id);
$tpl->set('price_info', $price_info);
// Get the Base Price of the Product
$base_price_info = $this->get_price($product_id, true);
$tpl->set('base_price_info', $base_price_info);
if ($price_info === false) {
$price_info = $base_price_info;
}
$html = "";
$undiscounted_price = 0;
if (isset($price_info["product_price_id"])) {
if ($base_price_info["product_price"] == $price_info["product_price"]) {
$price = $base_price = $GLOBALS['CURRENCY']->convert($base_price_info["product_price"], $price_info['product_currency']);
} else {
$base_price = $GLOBALS['CURRENCY']->convert($base_price_info["product_price"], $price_info['product_currency']);
$price = $GLOBALS['CURRENCY']->convert($price_info["product_price"], $price_info['product_currency']);
}
if ($auth["show_price_including_tax"] == 1) {
$my_taxrate = $this->get_product_taxrate($product_id);
$base_price += $my_taxrate * $base_price;
} else {
$my_taxrate = 0;
}
// Calculate discount
if (!empty($discount_info["amount"])) {
$undiscounted_price = $base_price;
switch ($discount_info["is_percent"]) {
case 0:
// If we subtract discounts BEFORE tax
if (PAYMENT_DISCOUNT_BEFORE == '1') {
// and if our prices are shown with tax
if ($auth["show_price_including_tax"] == 1) {
// then we add tax to the (untaxed) discount
$discount_info['amount'] += $my_taxrate * $discount_info['amount'];
}
// but if our prices are shown without tax
// we just leave the (untaxed) discount amount as it is
}
// But, if we subtract discounts AFTER tax
// and if our prices are shown with tax
// we just leave the (untaxed) discount amount as it is
// but if prices are shown without tax
// we just leave the (untaxed) discount amount as it is
// even though this is not really a good combination of settings
$base_price -= $discount_info["amount"];
break;
case 1:
$base_price *= (100 - $discount_info["amount"]) / 100;
break;
}
}
$text_including_tax = "";
if (!empty($my_taxrate)) {
$tax = $my_taxrate * 100;
// only show "including x % tax" when it shall
// not be hidden
if (!$hide_tax && $auth["show_price_including_tax"] == 1 && VM_PRICE_SHOW_INCLUDINGTAX) {
$text_including_tax = $VM_LANG->_('PHPSHOP_INCLUDING_TAX');
eval("\$text_including_tax = \"{$text_including_tax}\";");
}
}
// Check if we need to display a Table with all Quantity <=> Price Relationships
if ($base_price_info["product_has_multiple_prices"] && !$hide_tax) {
$db = new ps_DB();
// Quantity Discount Table
$q = "SELECT product_price, product_currency, price_quantity_start, price_quantity_end \n\t\t\t\t\t\t\tFROM #__{vm}_product_price\n\t\t\t\t \t\t\tWHERE product_id='{$product_id}' \n\t\t\t\t \t\t\tAND shopper_group_id='" . $auth["shopper_group_id"] . "' \n\t\t\t\t \t\t\tORDER BY price_quantity_start";
$db->query($q);
// $prices_table = "<table align=\"right\">
$prices_table = "<table width=\"100%\">\n\t\t\t\t\t <thead><tr class=\"sectiontableheader\">\n\t\t\t\t\t <th>" . $VM_LANG->_('PHPSHOP_CART_QUANTITY') . "</th>\n\t\t\t\t\t <th>" . $VM_LANG->_('PHPSHOP_CART_PRICE') . "</th>\n\t\t\t\t\t </tr></thead>\n\t\t\t\t\t <tbody>";
$i = 1;
if ($db->num_rows() == 0) {
// get the vendor ID
$q = "SELECT vendor_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
$db->setQuery($q);
//.........这里部分代码省略.........
示例3: vmGet
/**
* Lists all child/sister products of the given product
*
* @param int $product_id
* @return string HTML code with Items, attributes & price
*/
function list_attribute_list($product_id, $display_use_parent, $child_link, $display_type, $cls_sfuffix, $child_ids, $dw, $aw, $display_header, $product_list_type, $product_list)
{
global $CURRENCY_DISPLAY, $mm_action_url;
require_once CLASSPATH . 'ps_product.php';
$ps_product = new ps_product();
require_once CLASSPATH . 'ps_product_type.php';
$ps_product_type = new ps_product_type();
$Itemid = vmGet($_REQUEST, 'Itemid', "");
$category_id = vmGet($_REQUEST, 'category_id', "");
$curr_product = vmGet($_REQUEST, 'product_id', "");
$db = new ps_DB();
$db_sku = new ps_DB();
$db_item = new ps_DB();
$tpl = vmTemplate::getInstance();
$price = $ps_product->get_adjusted_attribute_price($product_id);
$tpl->set("cls_suffix", $cls_sfuffix);
$tpl->set("product_id", $product_id);
$tpl->set("display_header", $display_header);
$tpl->set("display_product_type", $product_list_type);
$tpl->set("product_price", $price['product_price']);
$html = '';
// Get list of children
$pp = $ps_product->parent_has_children($product_id);
if ($pp) {
$q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_parent_id='{$product_id}' ";
} else {
$q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_id='{$product_id}' ";
}
if ($child_ids) {
$ids = explode(",", $child_ids);
$child_array = array();
$parent_array = array();
foreach ($ids as $extra_id) {
if ($ps_product->parent_has_children($extra_id)) {
$parent_array[] = $extra_id;
} else {
$child_array[] = $extra_id;
}
}
$parent_ids = implode(',', $parent_array);
$child_ids = implode(',', $child_array);
if ($child_ids) {
$q .= "UNION ALL SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_id IN ({$child_ids}) ";
}
if ($parent_ids) {
$q .= "UNION ALL SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_parent_id IN ({$parent_ids})";
}
}
$db->query($q);
if ($pp) {
$master_id = $product_id;
} else {
$master_id = $db->f("product_id");
}
$main_master = $master_id;
$master_child_count = 0;
if ($db->num_rows() < 1) {
// Try to Get list of sisters & brothers
$q = "SELECT product_parent_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
$db->setQuery($q);
$db->query();
$child_id = $product_id;
$product_id = $db->f("product_parent_id") ? $db->f("product_parent_id") : $product_id;
$parent_id = $db->f("product_parent_id");
$q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock FROM #__{vm}_product WHERE product_parent_id='" . $db->f("product_parent_id") . "' AND product_parent_id<>0 AND product_publish='Y'";
$db->query($q);
}
if ($db->num_rows() > 0) {
$products = array();
$headings = array();
$i = 0;
$attrib_heading = array();
$ci = 0;
while ($db->next_record()) {
$parent_id = $db->f("product_parent_id");
if ($db->f("product_id") != $curr_product && @$child_id) {
continue;
}
// Start row for this child
$q = "SELECT product_id, attribute_name FROM #__{vm}_product_attribute_sku ";
$q .= "WHERE product_id='" . $db->f("product_parent_id") . "' ORDER BY attribute_list ASC";
$db_sku->query($q);
$attrib_value = array();
while ($db_sku->next_record()) {
$q = "SELECT attribute_name,attribute_value ";
$q .= "FROM #__{vm}_product_attribute WHERE ";
$q .= "product_id='" . $db->f("product_id") . "' AND ";
$q .= "attribute_name='" . $db_sku->f("attribute_name") . "'";
$db_item->setQuery($q);
$db_item->query();
while ($db_item->next_record()) {
if ($ci == 0) {
$attrib_heading[] = $db_item->f("attribute_name");
$tpl->set('headings', $attrib_heading);
//.........这里部分代码省略.........
示例4: while
function list_attribute($product_id, $fils = true)
{
global $VM_LANG, $CURRENCY_DISPLAY;
$ps_product = new ps_product();
$db = new ps_DB();
$db_sku = new ps_DB();
$db_item = new ps_DB();
// Get list of children
if ($fils) {
$q = "SELECT product_id,product_name FROM #__{vm}_product WHERE product_parent_id='{$product_id}' AND product_publish='Y'";
} else {
$q = "SELECT product_parent_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
$db->setQuery($q);
$db->query();
$db->next_record();
$product_parent_id = $db->f("product_parent_id");
$q = "SELECT product_id,product_name FROM #__{vm}_product WHERE product_parent_id='{$product_parent_id}' AND product_publish='Y'";
}
$db->setQuery($q);
$db->query();
if ($db->num_rows() > 0) {
$display = '<select name="product_id" onChange="this.form.add_product_validate.value=0;this.form.submit();">';
$display .= '<option value="-1">Choisissez un produit item</option>';
while ($db->next_record()) {
$display .= '<option value="' . $db->f("product_id") . '"';
if ($product_id == $db->f("product_id")) {
$display .= ' selected="yes"';
}
$display .= '>' . $db->f("product_name");
// For each child get attribute values by looping through attribute list
$q = "SELECT product_id, attribute_name FROM #__{vm}_product_attribute_sku ";
$q .= "WHERE product_id='{$product_id}' ORDER BY attribute_list ASC";
$db_sku->setQuery($q);
$db_sku->query();
while ($db_sku->next_record()) {
$q = "SELECT attribute_name, attribute_value, product_id ";
$q .= "FROM #__{vm}_product_attribute WHERE ";
$q .= "product_id='" . $db->f("product_id") . "' AND ";
$q .= "attribute_name='" . $db_sku->f("attribute_name") . "'";
$db_item->setQuery($q);
$db_item->query();
while ($db_item->next_record()) {
$display .= ' - ' . $db_item->f("attribute_name") . " ";
$display .= "(" . $db_item->f("attribute_value") . ")";
if (!$db_sku->is_last_record()) {
$display .= '; ';
}
}
}
// Attributes for this item are done.
// Now get item price
$price = $ps_product->get_price($db->f("product_id"));
if ($_SESSION["auth"]["show_price_including_tax"] == 1) {
$tax_rate = 1 + $ps_product->get_product_taxrate($db->f("product_id"));
$price['product_price'] *= $tax_rate;
}
$display .= ' - ' . $CURRENCY_DISPLAY->getFullValue($price["product_price"]);
$display .= '</option>';
}
$display .= '</select>';
} else {
$display = "<input type=\"hidden\" name=\"product_id\" value=\"{$product_id}\" />\n";
}
return $display;
}
示例5: substr
function NVP_DoDirectPaymentRequest(&$d, $dbbt, $dbst, $order_total, $payment_action, $ordernum, $requireCVV)
{
global $vendor_mail, $vendor_currency, $VM_LANG;
if (isset($_SESSION['ccdata']['order_payment_number'])) {
$cc_first_digit = substr($_SESSION['ccdata']['order_payment_number'], 0, 1);
$cc_first_2_digits = substr($_SESSION['ccdata']['order_payment_number'], 0, 2);
// Figure out the card type.
switch ($cc_first_digit) {
case "4":
$cc_type = urlencode("Visa");
break;
case "5":
$cc_type = urlencode("MasterCard");
break;
case "3":
switch ($cc_first_2_digits) {
case "34":
$cc_type = urlencode("Amex");
break;
case "37":
$cc_type = urlencode("Amex");
break;
case "30":
$cc_type = urlencode("Discover");
break;
case "36":
$cc_type = urlencode("Discover");
break;
case "38":
$cc_type = urlencode("Discover");
break;
default:
return false;
break;
}
break;
case "6":
$cc_type = urlencode("Discover");
break;
default:
return false;
break;
}
//Gather all required data
//Remove any dashes or spaces in the credit card number
$tmp_number = str_replace('-', '', $_SESSION['ccdata']['order_payment_number']);
$tmp_number = str_replace(' ', '', $tmp_number);
$cc_number = urlencode($tmp_number);
if (isset($_SESSION['ccdata']['credit_card_code'])) {
$cc_cvv2 = urlencode($_SESSION['ccdata']['credit_card_code']);
} else {
if ($requireCVV == 'YES') {
return false;
}
}
$cc_expires_month = $_SESSION['ccdata']['order_payment_expire_month'];
$cc_expires_year = $_SESSION['ccdata']['order_payment_expire_year'];
//$cc_owner = ($_SESSION['ccdata']['order_payment_name']);
//$cc_first = urlencode(substr($cc_owner, 0,(strrpos($cc_owner, " "))));
//$cc_last = urlencode(substr($cc_owner,(strrpos($cc_owner, ' ') + 1),strlen($cc_owner)));
$cc_expDate = urlencode($cc_expires_month . $cc_expires_year);
$subject = urlencode('');
$payer = urlencode($dbbt->f("user_email"));
$first_name = urlencode(substr($dbbt->f("first_name"), 0, 50));
$last_name = urlencode(substr($dbbt->f("last_name"), 0, 50));
$currency_type = $GLOBALS['product_currency'];
$ps_checkout = new ps_checkout();
$order_totals = $ps_checkout->calc_order_totals($d);
$tax_total = round($d['order_tax'], 2);
$ship_total = isset($d['shipping_total']) ? round($d['shipping_total'], 2) : 0;
$useshipping = PAYPAL_API_USE_SHIPPING;
$db_new = new ps_DB();
$query_str = "SELECT * FROM #__{vm}_country WHERE country_3_code='" . substr($dbbt->f("country"), 0, 60) . "'";
$db_new->setQuery($query_str);
$db_new->query();
$db_new->next_record();
$address_street1 = urlencode(substr($dbbt->f("address_1"), 0, 60));
$address_city = urlencode(substr($dbbt->f("city"), 0, 40));
$address_state = urlencode(substr($dbbt->f("state"), 0, 40));
$address_country = urlencode($db_new->f("country_2_code"));
$address_zip = urlencode(substr($dbbt->f("zip"), 0, 20));
$query_str = "SELECT * FROM #__{vm}_country WHERE country_3_code='" . substr($dbst->f("country"), 0, 60) . "'";
$db_new->setQuery($query_str);
$db_new->query();
$db_new->next_record();
$ship_name = urlencode(trim(substr($dbst->f("first_name"), 0, 50) . ' ' . substr($dbst->f("last_name"), 0, 50)));
$ship_street1 = urlencode(substr($dbst->f("address_1"), 0, 60));
$ship_street2 = urlencode(substr($dbst->f("address_2"), 0, 60));
$ship_city = urlencode(substr($dbst->f("city"), 0, 40));
$ship_state = urlencode(substr($dbst->f("state"), 0, 40));
$ship_country = urlencode($db_new->f("country_2_code"));
$ship_zip = urlencode(substr($dbst->f("zip"), 0, 20));
//Begin putting together our NVP Request
$nvpreq = "&PAYMENTACTION={$payment_action}" . "&IPADDRESS=" . $_SERVER['REMOTE_ADDR'] . "&CREDITCARDTYPE={$cc_type}" . "&ACCT={$cc_number}" . "&EXPDATE={$cc_expDate}" . "&EMAIL={$payer}" . "&FIRSTNAME={$first_name}" . "&LASTNAME={$last_name}";
if ($requireCVV == 'YES') {
if (isset($cc_cvv2)) {
$nvpreq .= "&CVV2={$cc_cvv2}";
} else {
return false;
}
//.........这里部分代码省略.........
示例6: add
/**
* creates a new Product Type record
* @author Zdenek Dvorak
*
* @param array $d
* @return boolean
*/
function add(&$d)
{
global $VM_LANG;
$db = new ps_DB();
if ($this->validate_add($d)) {
// find product_type_id
$q = "SELECT MAX(product_type_id) AS product_type_id FROM #__{vm}_product_type";
$db->query($q);
$db->next_record();
$product_type_id = intval($db->f("product_type_id")) + 1;
// Let's find out the last Product Type
$q = "SELECT MAX(product_type_list_order) AS list_order FROM #__{vm}_product_type";
$db->query($q);
$db->next_record();
$list_order = intval($db->f("list_order")) + 1;
if ($d["product_type_publish"] != "Y") {
$d["product_type_publish"] = "N";
}
$fields = array('product_type_id' => $product_type_id, 'product_type_name' => vmGet($d, 'product_type_name'), 'product_type_description' => vmGet($d, 'product_type_description'), 'product_type_publish' => vmGet($d, 'product_type_publish'), 'product_type_browsepage' => vmGet($d, 'product_type_browsepage'), 'product_type_flypage' => vmGet($d, 'product_type_flypage'), 'product_type_list_order' => $list_order);
$db->buildQuery('INSERT', '#__{vm}_product_type', $fields);
$db->query();
$_REQUEST['product_type_id'] = $product_type_id;
// Make new table product_type_<id>
$q = "CREATE TABLE `#__{vm}_product_type_";
$q .= $product_type_id . "` (";
$q .= "`product_id` int(11) NOT NULL,";
$q .= "PRIMARY KEY (`product_id`)";
$q .= ") TYPE=MyISAM;";
$db->setQuery($q);
if ($db->query() === false) {
$GLOBALS['vmLogger']->err($VM_LANG->_('VM_PRODUCT_TYPE_ADD_FAILED'));
return false;
} else {
$GLOBALS['vmLogger']->info($VM_LANG->_('VM_PRODUCT_TYPE_ADDED'));
return true;
}
} else {
return False;
}
}
示例7: array
function get_price($product_id, $quantity = 0, $check_multiple_prices = false, $result_attributes = '')
{
if ($check_multiple_prices) {
$db = new ps_DB();
// Get the vendor id for this product.
$q = "SELECT vendor_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
$db->setQuery($q);
$db->query();
$db->next_record();
$vendor_id = $db->f("vendor_id");
$q = "SELECT svx.shopper_group_id, sg.shopper_group_discount FROM #__{vm}_shopper_vendor_xref svx, #__{vm}_orders o, #__{vm}_shopper_group sg";
$q .= " WHERE svx.user_id=o.user_id AND sg.shopper_group_id=svx.shopper_group_id AND o.order_id=" . $this->order_id;
$db->query($q);
$db->next_record();
$shopper_group_id = $db->f("shopper_group_id");
$shopper_group_discount = $db->f("shopper_group_discount");
// Get the default shopper group id for this vendor
$q = "SELECT shopper_group_id,shopper_group_discount FROM #__{vm}_shopper_group WHERE ";
$q .= "vendor_id='{$vendor_id}' AND `default`='1'";
$db->setQuery($q);
$db->query();
$db->next_record();
$default_shopper_group_id = $db->f("shopper_group_id");
$default_shopper_group_discount = $db->f("shopper_group_discount");
// Get the product_parent_id for this product/item
$q = "SELECT product_parent_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
$db->setQuery($q);
$db->query();
$db->next_record();
$product_parent_id = $db->f("product_parent_id");
$price_info = array();
if (!$check_multiple_prices) {
/* Added for Volume based prices */
// This is an important decision: we add up all product quantities with the same product_id,
// regardless to attributes. This gives "real" volume based discount, because our simple attributes
// depend on one and the same product_id
$volume_quantity_sql = " AND (('{$quantity}' >= price_quantity_start AND '{$quantity}' <= price_quantity_end)\n OR (price_quantity_end='0') OR ('{$quantity}' > price_quantity_end)) ORDER BY price_quantity_end DESC";
/* End Addition */
} else {
$volume_quantity_sql = " ORDER BY price_quantity_start";
}
// Getting prices
//
// If the shopper group has a price then show it, otherwise
// show the default price.
if (!empty($shopper_group_id)) {
$q = "SELECT product_price, product_price_id, product_currency FROM #__{vm}_product_price WHERE product_id='{$product_id}' AND ";
$q .= "shopper_group_id='{$shopper_group_id}' {$volume_quantity_sql}";
$db->setQuery($q);
$db->query();
if ($db->next_record()) {
$price_info["product_price"] = $db->f("product_price");
if ($check_multiple_prices) {
$price_info["product_base_price"] = $db->f("product_price");
$price_info["product_has_multiple_prices"] = $db->num_rows() > 1;
}
$price_info["product_price_id"] = $db->f("product_price_id");
$price_info["product_currency"] = $db->f("product_currency");
$price_info["item"] = true;
$GLOBALS['product_info'][$product_id]['price'] = $price_info;
return $GLOBALS['product_info'][$product_id]['price'];
}
}
// Get default price
$q = "SELECT product_price, product_price_id, product_currency FROM #__{vm}_product_price WHERE product_id='{$product_id}' AND ";
$q .= "shopper_group_id='{$default_shopper_group_id}' {$volume_quantity_sql}";
$db->setQuery($q);
$db->query();
if ($db->next_record()) {
$price_info["product_price"] = $db->f("product_price") * ((100 - $shopper_group_discount) / 100);
if ($check_multiple_prices) {
$price_info["product_base_price"] = $price_info["product_price"];
$price_info["product_has_multiple_prices"] = $db->num_rows() > 1;
}
$price_info["product_price_id"] = $db->f("product_price_id");
$price_info["product_currency"] = $db->f("product_currency");
$price_info["item"] = true;
$GLOBALS['product_info'][$product_id]['price'] = $price_info;
return $GLOBALS['product_info'][$product_id]['price'];
}
// Maybe its an item with no price, check again with product_parent_id
if (!empty($shopper_group_id)) {
$q = "SELECT product_price, product_price_id, product_currency FROM #__{vm}_product_price WHERE product_id='{$product_parent_id}' AND ";
$q .= "shopper_group_id='{$shopper_group_id}' {$volume_quantity_sql}";
$db->setQuery($q);
$db->query();
if ($db->next_record()) {
$price_info["product_price"] = $db->f("product_price");
if ($check_multiple_prices) {
$price_info["product_base_price"] = $db->f("product_price");
$price_info["product_has_multiple_prices"] = $db->num_rows() > 1;
}
$price_info["product_price_id"] = $db->f("product_price_id");
$price_info["product_currency"] = $db->f("product_currency");
$GLOBALS['product_info'][$product_id]['price'] = $price_info;
return $GLOBALS['product_info'][$product_id]['price'];
}
}
$q = "SELECT product_price, product_price_id, product_currency FROM #__{vm}_product_price WHERE product_id='{$product_parent_id}' AND ";
$q .= "shopper_group_id='{$default_shopper_group_id}' {$volume_quantity_sql}";
//.........这里部分代码省略.........
示例8: time
//.........这里部分代码省略.........
WHERE product_id=".$db->f("product_id");
$dbu->query( $q );
}
else {
$q = "UPDATE #__{vm}_product
SET product_in_stock=product_in_stock+".$db->f("product_quantity").",
product_sales=product_sales-".$db->f("product_quantity")."
WHERE product_id=".$db->f("product_id");
$dbu->query( $q );
}
}
}
// Update the Order Items' status
$q = "SELECT order_item_id FROM #__{vm}_order_item WHERE order_id=".$db->getEscaped($d['order_id']);
$db->query($q);
$dbu = new ps_DB;
while ($db->next_record()) {
$item_id = $db->f("order_item_id");
$fields =array( 'order_status'=> $d["order_status"],
'mdate'=> $timestamp );
$dbu->buildQuery('UPDATE', '#__{vm}_order_item', $fields, "WHERE order_item_id='" .(int)$item_id . "'");
$dbu->query();
}
if ($d["order_status"] == "C" || $d["order_status"] == "P")
{
//////////////////////////////////////////////////////////////////////////
// OSE added
//////////////////////////////////////////////////////////////////////////
//////////////Joomla Database Class//////////////
require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php');
require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'helpers'.DS.'oseMscPublic.php');
$jdb = &JFactory::getDBO();
$jquery = "SELECT user_id FROM `#__vm_orders` WHERE `order_id` = '" . $db->getEscaped($d['order_id']) . "'";
$jdb->setQuery($jquery);
$user_id = $jdb->loadResult();
$jquery = "SELECT a.product_id, b.category_id FROM `#__vm_order_item` as a, `#__vm_product_category_xref` as b WHERE a.`order_id` = '" . $db->getEscaped($d['order_id']) . "' AND a.`product_id` = b.`product_id`";
$jdb->setQuery($jquery);
$results = $jdb->loadObjectList();
$cart = oseMscPublic::getCart();
if (empty($results))
{
$jquery = "SELECT a.product_id, b.category_id, c.product_parent_id FROM `#__vm_order_item` as a, `#__vm_product_category_xref` as b, `#__vm_product` as c WHERE a.`order_id` = '" . $db->getEscaped($d['order_id']) . "' AND a.`product_id` = c.`product_id` AND b.`product_id` = c.`product_parent_id`";
$jdb->setQuery($jquery);
$results = $jdb->loadObjectList();
}
foreach ($results as $result)
{
//////////////////////////////////////////////////
$product_id = $result->product_id;
$jquery = "SELECT * FROM `#__osemsc_ext` WHERE `type` = 'vm'";
$jdb->setQuery($jquery);
$jdb->query();
$rows = $jdb->loadObjectList();
foreach ($rows as $row)
{
$msc_data = oseJson::decode($row->params);
$left_var = "";
$right_var = "";
if ($msc_data->category_id > 0)
{
$left_var = $result->category_id;
$right_var = $msc_data->category_id;
}
else
{
示例9:
/**
* Should delete a Parameter form Product Type
* and drop column from table product_type_<id>
*/
function delete_record($record_id, &$d)
{
$db = new ps_DB();
/** Find parameter_type of deleted parameter */
$q = "SELECT parameter_type FROM #__{vm}_product_type_parameter";
$q2 = " WHERE product_type_id='" . $d["product_type_id"] . "' AND parameter_name='" . $db->getEscaped($record_id) . "'";
$db->query($q . $q2);
if ($db->next_record()) {
$parameter_type = $db->f("parameter_type");
} else {
$parameter_type = "B";
}
// Error - dont delete (maybe nonexisted) column from #__{vm}_product_type_XX
$q = "DELETE FROM #__{vm}_product_type_parameter";
$db->setQuery($q . $q2);
$db->query();
// Delete index - deleted automaticaly
/* $q = "ALTER TABLE `#__{vm}_product_type_";
$q .= $d["product_type_id"]."` DROP INDEX `idx_product_type_".$d["product_type_id"]."_";
$q .= $d["parameter_name"]."`;";
$db->setQuery($q); $db->query();*/
if ($parameter_type != "B") {
// != Break Line
// Delete column
$q = "ALTER TABLE #__{vm}_product_type_" . $d["product_type_id"] . " DROP `" . $db->getEscaped($record_id) . "`";
$db->setQuery($q);
$db->query();
}
return True;
}
示例10: getUserFields
/**
* This function allows you to get an object list of user fields
*
* @param string $section The section the fields belong to (e.g. 'registration' or 'account')
* @param boolean $required_only
* @param mixed $sys When left empty, doesn't filter by sys
* @return array
*/
function getUserFields($section = 'registration', $required_only = false, $sys = '', $exclude_delimiters = false, $exclude_skipfields = false)
{
$db = new ps_DB();
$q = "SELECT f.* FROM `#__{vm}_userfield` f" . "\n WHERE f.published=1";
if ($section != 'bank' && $section != '') {
$q .= "\n AND f.`{$section}`=1";
} elseif ($section == 'bank') {
$q .= "\n AND f.name LIKE '%bank%'";
}
if ($exclude_delimiters) {
$q .= "\n AND f.type != 'delimiter' ";
}
if ($required_only) {
$q .= "\n AND f.required=1";
}
if ($sys !== '') {
if ($sys == '1') {
$q .= "\n AND f.sys=1";
} elseif ($sys == '0') {
$q .= "\n AND f.sys=0";
}
}
if ($exclude_skipfields) {
$q .= "\n AND FIND_IN_SET( f.name, '" . implode(',', ps_userfield::getSkipFields()) . "') = 0 ";
}
$q .= "\n ORDER BY f.ordering";
$db->setQuery($q);
$userFields = $db->loadObjectList();
return $userFields;
}
示例11: getOrderInfo
function getOrderInfo($order_id)
{
$qv = "SELECT *\n\t\t FROM `#__{vm}_orders` as o\n\t\t left join `#__{vm}_order_user_info` as oi on o.order_id = oi.order_id \n\t\t WHERE o.order_id='" . $order_id . "'";
$db_ap = new ps_DB();
$db_ap->setQuery($qv);
$result = $db_ap->loadObjectList();
return $result[0];
}
示例12: intval
/**
* Sends the requested file to the browser
* and assures that the requested file is no payable product download file
* @author soeren
* @param int $file_id
* @param int $product_id
* @return mixed
*/
function send_file($file_id, $product_id)
{
global $VM_LANG, $vmLogger, $mosConfig_absolute_path;
$dbf = new ps_DB();
$html = "";
$sql = 'SELECT attribute_value FROM #__{vm}_product_attribute WHERE `product_id` = ' . intval($product_id) . ' AND attribute_name=\'download\'';
$dbf->query($sql);
$dbf->next_record();
$exclude_filename = $GLOBALS['vmInputFilter']->safeSQL($dbf->f("attribute_value"));
$sql = 'SELECT file_mimetype, file_name' . ' FROM `#__{vm}_product_files` WHERE ';
if ($exclude_filename) {
$sql .= ' file_title != \'' . $exclude_filename . '\' AND ';
}
$sql .= ' file_product_id = \'' . $product_id . '\' AND file_published = \'1\' AND file_id = \'' . $file_id . '\' AND file_is_image = \'0\'';
$dbf->setQuery($sql);
$dbf->query();
if (!$dbf->next_record()) {
$vmLogger->err($VM_LANG->_('PHPSHOP_FILES_NOT_FOUND', false));
return false;
}
$filename = $mosConfig_absolute_path . str_replace($mosConfig_absolute_path, '', $dbf->f("file_name"));
// dump anything in the buffer
while (@ob_end_clean()) {
}
if (strtolower(substr($filename, 0, 4)) == 'http') {
vmRedirect($filename);
}
if ($filename) {
require_once CLASSPATH . 'connectionTools.class.php';
vmConnector::sendFile($filename, $dbf->f("file_mimetype"));
$GLOBALS['vm_mainframe']->close(true);
} else {
$vmLogger->err($VM_LANG->_('PHPSHOP_FILES_NOT_FOUND', false));
}
return true;
}
示例13: checkMenuItems
function checkMenuItems($parameter, $value)
{
global $mainframe;
$db = new ps_DB();
if (!isset($mainframe->vm_menuitems)) {
$db->setQuery("SELECT id, params FROM #__menu WHERE link='index.php?option=com_virtuemart' AND published=1");
$mainframe->vm_menuitems = $db->loadAssocList();
if (!is_array($mainframe->vm_menuitems)) {
$mainframe->vm_menuitems = array();
// Query failed, empty result
}
}
foreach ($mainframe->vm_menuitems as $chkmenu) {
if (strpos($chkmenu['params'], $parameter . "=" . $value . "\n") !== false) {
return $chkmenu['id'];
}
}
return false;
}
示例14:
/**
* Lists Shipping Methods of all published Shipping Modules
*
* @param string $ship_to_info_id
* @param string $shipping_method_id
*/
function list_shipping_methods($ship_to_info_id = null, $shipping_method_id = null)
{
global $PSHOP_SHIPPING_MODULES, $vmLogger, $auth, $weight_total;
if (empty($ship_to_info_id)) {
// Get the Bill to user_info_id
$database = new ps_DB();
$database->setQuery("SELECT user_info_id FROM #__{vm}_user_info WHERE user_id=" . $auth['user_id'] . " AND address_type='BT'");
$vars["ship_to_info_id"] = $_REQUEST['ship_to_info_id'] = $database->loadResult();
} else {
$vars['ship_to_info_id'] = $ship_to_info_id;
}
$vars['shipping_rate_id'] = $shipping_method_id;
$vars["weight"] = $weight_total;
$vars['zone_qty'] = vmRequest::getInt('zone_qty', 0);
$i = 0;
$theme = new $GLOBALS['VM_THEMECLASS']();
$theme->set_vars(array('vars' => $vars, 'PSHOP_SHIPPING_MODULES' => $PSHOP_SHIPPING_MODULES));
echo $theme->fetch('checkout/list_shipping_methods.tpl.php');
}
示例15: array
/**
* Creates navigation list of categories
* @author pablo
* @author soeren
* @param int $category_id
*/
function get_navigation_list($category_id)
{
global $sess, $mosConfig_live_site;
$db = new ps_DB();
static $i = 0;
static $category_list = array();
$q = "SELECT category_id, category_name,category_parent_id, category_child_id FROM #__{vm}_category, #__{vm}_category_xref WHERE ";
$q .= "#__{vm}_category_xref.category_child_id='{$category_id}' ";
$q .= "AND #__{vm}_category.category_id='{$category_id}'";
$db->setQuery($q);
$db->query();
$db->next_record();
$category_list[$i]['category_id'] = $db->f("category_id");
$category_list[$i]['category_name'] = $db->f("category_name");
if ($db->f("category_parent_id")) {
$i++;
array_merge($category_list, $this->get_navigation_list($db->f("category_parent_id")));
}
return $category_list;
}