本文整理汇总了PHP中ps_DB::last_insert_id方法的典型用法代码示例。如果您正苦于以下问题:PHP ps_DB::last_insert_id方法的具体用法?PHP ps_DB::last_insert_id怎么用?PHP ps_DB::last_insert_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ps_DB
的用法示例。
在下文中一共展示了ps_DB::last_insert_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Adds a new Vendor Category
*
* @param array $d
* @return boolean
*/
function add(&$d)
{
$db = new ps_DB();
if (!$this->validate_add($d)) {
return False;
}
$fields = array('vendor_category_name' => $d["vendor_category_name"], 'vendor_category_desc' => $d["vendor_category_desc"]);
$db->buildQuery('INSERT', '#__{vm}_vendor_category', $fields);
$res = $db->query();
if ($res !== false) {
$_REQUEST['vendor_category_id'] = $db->last_insert_id();
$GLOBALS['vmLogger']->info('The Vendor Category has been added.');
return true;
}
$GLOBALS['vmLogger']->err('Failed to add the Vendor Category.');
return false;
}
示例2: add
function add(&$d)
{
$db = new ps_DB();
$ps_vendor_id = $_SESSION["ps_vendor_id"];
$timestamp = time();
if (!$this->validate_add($d)) {
return False;
}
foreach ($d as $key => $value) {
$d[$key] = addslashes($value);
}
$q = "INSERT INTO #__{vm}_zone_shipping (zone_name, zone_cost, ";
$q .= "zone_limit, zone_description, zone_tax_rate) VALUES ('";
$q .= $d["zone_name"] . "','";
$q .= $d["zone_cost"] . "','";
$q .= $d["zone_limit"] . "','";
$q .= $d["zone_description"] . "','";
$q .= $d["zone_tax_rate"] . "')";
$db->query($q);
$db->next_record();
$_REQUEST['zone_id'] = $db->last_insert_id();
return True;
}
示例3: add
/**
* creates a new discount record
*
* @param array $d
* @return boolean
*/
function add(&$d)
{
global $VM_LANG;
$db = new ps_DB();
if (!empty($d["start_date"])) {
$day = substr($d["start_date"], 8, 2);
$month = substr($d["start_date"], 5, 2);
$year = substr($d["start_date"], 0, 4);
$d["start_date"] = mktime(0, 0, 0, $month, $day, $year);
} else {
$d["start_date"] = 0;
}
if (!empty($d["end_date"])) {
$day = substr($d["end_date"], 8, 2);
$month = substr($d["end_date"], 5, 2);
$year = substr($d["end_date"], 0, 4);
$d["end_date"] = mktime(0, 0, 0, $month, $day, $year);
} else {
$d["end_date"] = 0;
}
if (!$this->validate_add($d)) {
return False;
}
$fields = array('amount' => (double) vmGet($d, 'amount'), 'is_percent' => (int) vmGet($d, 'is_percent'), 'start_date' => $d["start_date"], 'end_date' => $d["end_date"]);
$db->buildQuery('INSERT', '#__{vm}_product_discount', $fields);
$db->query();
$GLOBALS['vmLogger']->info($VM_LANG->_('VM_PRODUCT_DISCOUNT_ADDED'));
$_REQUEST['discount_id'] = $db->last_insert_id();
return True;
}
示例4: add
/**
* Creates a new tax record
* @author pablo
*
* @param arry $d The _REQUEST array
* @return boolean True on success, false on failure
*/
function add(&$d)
{
global $VM_LANG;
$db = new ps_DB();
$ps_vendor_id = $_SESSION["ps_vendor_id"];
$timestamp = time();
if (!$this->validate_add($d)) {
return False;
}
$fields = array('vendor_id' => $ps_vendor_id, 'tax_state' => vmget($d, 'tax_state'), 'tax_country' => vmget($d, 'tax_country'), 'tax_rate' => $d["tax_rate"], 'mdate' => $timestamp);
$db->buildQuery('INSERT', $this->getTable(), $fields);
if ($db->query() !== false) {
$_REQUEST['tax_rate_id'] = $db->last_insert_id();
$GLOBALS['vmLogger']->info($VM_LANG->_('VM_TAX_ADDED'));
return True;
}
$GLOBALS['vmLogger']->err($VM_LANG->_('VM_TAX_ADD_FAILED'));
return false;
}
示例5: add
/**
* Creates a new function record
* @author pablo, soeren
*
* @param array $d
* @return boolean
*/
function add(&$d)
{
$db = new ps_DB();
$timestamp = time();
if (!$this->validate_add($d)) {
return False;
}
if (is_array($d['function_perms'])) {
$d['function_perms'] = implode(',', $d['function_perms']);
}
$fields = array('function_name' => vmGet($d, 'function_name'), 'function_class' => vmGet($d, 'function_class'), 'function_method' => vmGet($d, 'function_method'), 'function_perms' => vmGet($d, 'function_perms'), 'module_id' => vmRequest::getInt('module_id'), 'function_description' => vmGet($d, 'function_description'));
$db->buildQuery('INSERT', '#__{vm}_function', $fields);
$db->query();
$_REQUEST['function_id'] = $db->last_insert_id();
return True;
}
示例6: add
/**
* Adds a Vendor Record
*
* @param array $d
* @return boolean
*/
function add(&$d)
{
global $vendor_currency;
$db = new ps_DB();
$timestamp = time();
if (!$this->validate_add($d)) {
return False;
}
if (!vmImageTools::process_images($d)) {
return false;
}
$d['display_style'][1] = ps_vendor::checkCurrencySymbol($d['display_style'][1]);
$d['display_style'] = implode("|", $d['display_style']);
if (empty($d['vendor_accepted_currencies'])) {
$d['vendor_accepted_currencies'] = array($vendor_currency);
}
$fields = array('vendor_name' => $d["vendor_name"], 'contact_last_name' => $d["contact_last_name"], 'contact_first_name' => $d["contact_first_name"], 'contact_middle_name' => $d["contact_middle_name"], 'contact_title' => $d["contact_title"], 'contact_phone_1' => $d["contact_phone_1"], 'contact_phone_2' => $d["contact_phone_2"], 'contact_fax' => $d["contact_fax"], 'contact_email' => $d["contact_email"], 'vendor_phone' => $d["vendor_phone"], 'vendor_address_1' => $d["vendor_address_1"], 'vendor_address_2' => $d["vendor_address_2"], 'vendor_city' => $d["vendor_city"], 'vendor_state' => $d["vendor_state"], 'vendor_country' => $d["vendor_country"], 'vendor_zip' => $d["vendor_zip"], 'vendor_store_name' => $d["vendor_store_name"], 'vendor_store_desc' => $d["vendor_store_desc"], 'vendor_category_id' => $d["vendor_category_id"], 'vendor_image_path' => $d["vendor_image_path"], 'vendor_thumb_image' => $d["vendor_thumb_image"], 'vendor_full_image' => $d["vendor_full_image"], 'vendor_currency' => $d["vendor_currency"], 'vendor_url' => $d["vendor_url"], 'cdate' => $timestamp, 'mdate' => $timestamp, 'vendor_terms_of_service' => $d["vendor_terms_of_service"], 'vendor_min_pov' => $d["vendor_min_pov"], 'vendor_currency_display_style' => $d["display_style"], 'vendor_freeshipping' => $d['vendor_freeshipping'], 'vendor_accepted_currencies' => implode(',', $d['vendor_accepted_currencies']), 'vendor_address_format' => $d['vendor_address_format'], 'vendor_date_format' => $d['vendor_date_format']);
$db->buildQuery('INSERT', '#__{vm}_vendor', $fields);
$db->query();
// Get the assigned vendor_id //
$_REQUEST['vendor_id'] = $db->last_insert_id();
$GLOBALS['vmLogger']->info('The Vendor has been added.');
/* Insert default- shopper group */
$q = "INSERT INTO #__{vm}_shopper_group (";
$q .= "`vendor_id`,";
$q .= "`shopper_group_name`,";
$q .= "`shopper_group_desc`,`default`) VALUES ('";
$q .= $d["vendor_id"] . "',";
$q .= "'-default-',";
$q .= "'Default shopper group for " . $d["vendor_name"] . "','1')";
$db->query($q);
return True;
}
示例7: add
/**
* Function to add a new product into the product table
*
* @param array $d The input vars
* @return boolean True, when the product was added, false when not
*/
function add(&$d)
{
global $perm, $vmLogger, $VM_LANG;
$database = new ps_DB();
if (!$this->validate($d)) {
return false;
}
if (!vmImageTools::process_images($d)) {
return false;
}
$timestamp = time();
$db = new ps_DB();
$ps_vendor_id = $_SESSION["ps_vendor_id"];
if ($perm->check('admin')) {
$vendor_id = $d['vendor_id'];
} else {
$vendor_id = $ps_vendor_id;
}
// Insert into DB
$fields = array('vendor_id' => $vendor_id, 'product_parent_id' => vmRequest::getInt('product_parent_id'), 'product_sku' => vmGet($d, 'product_sku'), 'product_name' => vmGet($d, 'product_name'), 'product_desc' => vmRequest::getVar('product_desc', '', 'default', '', VMREQUEST_ALLOWHTML), 'product_s_desc' => vmRequest::getVar('product_s_desc', '', 'default', '', VMREQUEST_ALLOWHTML), 'product_thumb_image' => vmGet($d, 'product_thumb_image'), 'product_full_image' => vmGet($d, 'product_full_image'), 'product_publish' => $d['product_publish'], 'product_weight' => vmRequest::getFloat('product_weight'), 'product_weight_uom' => vmGet($d, 'product_weight_uom'), 'product_length' => vmRequest::getFloat('product_length'), 'product_width' => vmRequest::getFloat('product_width'), 'product_height' => vmRequest::getFloat('product_height'), 'product_lwh_uom' => vmGet($d, 'product_lwh_uom'), 'product_unit' => vmGet($d, 'product_unit'), 'product_packaging' => $d["product_box"] << 16 | $d["product_packaging"] & 0xffff, 'product_url' => vmGet($d, 'product_url'), 'product_in_stock' => vmRequest::getInt('product_in_stock'), 'attribute' => ps_product_attribute::formatAttributeX(), 'custom_attribute' => vmGet($d, 'product_custom_attribute'), 'product_available_date' => $d['product_available_date_timestamp'], 'product_availability' => vmGet($d, 'product_availability'), 'product_special' => $d['product_special'], 'child_options' => $d['child_options'], 'quantity_options' => $d['quantity_options'], 'product_discount_id' => vmRequest::getInt('product_discount_id'), 'cdate' => $timestamp, 'mdate' => $timestamp, 'product_tax_id' => vmRequest::getInt('product_tax_id'), 'child_option_ids' => vmGet($d, 'included_product_id'), 'product_order_levels' => $d['order_levels']);
$db->buildQuery('INSERT', '#__{vm}_product', $fields);
if ($db->query() === false) {
$vmLogger->err($VM_LANG->_('VM_PRODUCT_ADDING_FAILED', false));
return false;
}
$d["product_id"] = $_REQUEST['product_id'] = $db->last_insert_id();
// If is Item, add attributes from parent //
if ($d["product_parent_id"]) {
$q = "SELECT attribute_name FROM #__{vm}_product_attribute_sku ";
$q .= "WHERE product_id='" . vmRequest::getInt('product_parent_id') . "' ";
$q .= "ORDER BY attribute_list,attribute_name";
$db->query($q);
$db2 = new ps_DB();
$i = 0;
while ($db->next_record()) {
$i++;
$q = "INSERT INTO #__{vm}_product_attribute (`product_id`,`attribute_name`,`attribute_value`) VALUES ";
$q .= "('" . $d["product_id"] . "', '" . $db->f("attribute_name", false) . "', '" . vmGet($d, 'attribute_' . $i) . "')";
$db2->query($q);
}
} else {
// If is Product, Insert category ids
if (empty($d['product_categories']) || !is_array(@$d['product_categories'])) {
$d['product_categories'] = explode('|', $d['category_ids']);
}
foreach ($d["product_categories"] as $category_id) {
$db->query('SELECT MAX(`product_list`) as list_order FROM `#__{vm}_product_category_xref` WHERE `category_id`=' . $category_id);
$db->next_record();
$q = "INSERT INTO #__{vm}_product_category_xref ";
$q .= "(category_id,product_id,product_list) ";
$q .= "VALUES ('{$category_id}','" . $d["product_id"] . "', " . intval($db->f('max') + 1) . ")";
$db->setQuery($q);
$db->query();
}
}
$q = "INSERT INTO #__{vm}_product_mf_xref VALUES (";
$q .= "'" . $d['product_id'] . "', '" . vmRequest::getInt('manufacturer_id') . "')";
$db->setQuery($q);
$db->query();
if (!empty($d["related_products"])) {
/* Insert Pipe separated Related Product IDs */
$related_products = vmGet($d, "related_products");
$q = "INSERT INTO #__{vm}_product_relations ";
$q .= "(product_id, related_products) ";
$q .= "VALUES ('" . $d["product_id"] . "','" . $db->getEscaped($related_products) . "')";
$db->setQuery($q);
$db->query();
}
// ADD A PRICE, IF NOT EMPTY ADD 0
if (!empty($d['product_price'])) {
if (empty($d['product_currency'])) {
$d['product_currency'] = $_SESSION['vendor_currency'];
}
$d["price_quantity_start"] = 0;
$d["price_quantity_end"] = "";
require_once CLASSPATH . 'ps_product_price.php';
$my_price = new ps_product_price();
$my_price->add($d);
}
if (!empty($d['product_type_id'])) {
require_once CLASSPATH . 'ps_product_product_type.php';
$ps_product_product_type = new ps_product_product_type();
$ps_product_product_type->add($d);
// Product Type Parameters!
$this->handleParameters($d);
}
// CLONE PRODUCT additional code
if ($d["clone_product"] == "Y") {
// Clone Parent Product's Attributes
$q = "INSERT INTO #__{vm}_product_attribute_sku\n SELECT '" . $d["product_id"] . "', attribute_name, attribute_list \n FROM #__{vm}_product_attribute_sku WHERE product_id='" . (int) $d["old_product_id"] . "' ";
$db->query($q);
if (!empty($d["child_items"])) {
$database->query("SHOW COLUMNS FROM #__{vm}_product");
$rows = $database->record;
//.........这里部分代码省略.........
示例8: add
/**
* Adds a new Shopper Group
*
* @param array $d
* @return boolean
*/
function add(&$d)
{
global $perm, $vmLogger, $VM_LANG;
$hash_secret = "virtuemart";
if ($perm->check("admin")) {
$vendor_id = $d["vendor_id"];
} else {
$vendor_id = $_SESSION["ps_vendor_id"];
}
$db = new ps_DB();
$timestamp = time();
$default = @$d["default"] == "1" ? "1" : "0";
if (!$this->validate_add($d)) {
return False;
}
$user_id = md5(uniqid($hash_secret));
$fields = array('vendor_id' => $vendor_id, 'shopper_group_name' => $d["shopper_group_name"], 'shopper_group_desc' => $d["shopper_group_desc"], 'shopper_group_discount' => $d["shopper_group_discount"], 'show_price_including_tax' => $d["show_price_including_tax"], 'default' => $default);
$db->buildQuery('INSERT', '#__{vm}_shopper_group', $fields);
if ($db->query() !== false) {
$shopper_group_id = $db->last_insert_id();
vmRequest::setVar('shopper_group_id', $shopper_group_id);
$vmLogger->info($VM_LANG->_('SHOPPER_GROUP_ADDED'));
// Set all other shopper groups to be non-default, if this new shopper group shall be "default"
if ($default == "1") {
$q = "UPDATE #__{vm}_shopper_group ";
$q .= "SET `default`=0 ";
$q .= "WHERE shopper_group_id !=" . $shopper_group_id;
$q .= " AND vendor_id ={$vendor_id}";
$db->query($q);
$db->next_record();
}
return $_REQUEST['shopper_group_id'];
}
$vmLogger->err($VM_LANG->_('SHOPPER_GROUP_ADD_FAILED'));
return false;
}
示例9: add
/**
* creates a new manufacturer record
*
* @param array $d
* @return boolean
*/
function add(&$d)
{
global $VM_LANG;
$db = new ps_DB();
if (!$this->validate_add($d)) {
return false;
}
$fields = array('mf_name' => vmGet($d, 'mf_name'), 'mf_email' => vmGet($d, 'mf_email'), 'mf_desc' => vmGet($d, 'mf_desc', '', VMREQUEST_ALLOWHTML), 'mf_category_id' => vmRequest::getInt('mf_category_id'), 'mf_url' => vmGet($d, 'mf_url'));
$db->buildQuery('INSERT', '#__{vm}_manufacturer', $fields);
if ($db->query() !== false) {
$GLOBALS['vmLogger']->info($VM_LANG->_('VM_MANUF_ADDED'));
$_REQUEST['manufacturer_id'] = $db->last_insert_id();
return true;
}
return false;
}
示例10: add
/**
* Adds a new price record for a given product
*
* @param array $d
* @return boolean
*/
function add(&$d)
{
global $vmLogger, $VM_LANG;
if (!$this->validate($d)) {
return false;
}
if ($d["product_price"] === '') {
$vmLogger->err($VM_LANG->_('VM_PRODUCT_PRICE_NOTENTERED', false));
return false;
}
$timestamp = time();
if (empty($d["product_price_vdate"])) {
$d["product_price_vdate"] = '';
}
if (empty($d["product_price_edate"])) {
$d["product_price_edate"] = '';
}
$fields = array('product_id' => $d["product_id"], 'shopper_group_id' => vmRequest::getInt('shopper_group_id'), 'product_price' => vmRequest::getFloat('product_price'), 'product_currency' => vmGet($d, 'product_currency'), 'product_price_vdate' => vmGet($d, 'product_price_vdate'), 'product_price_edate' => vmGet($d, 'product_price_edate'), 'cdate' => $timestamp, 'mdate' => $timestamp, 'price_quantity_start' => vmRequest::getInt('price_quantity_start'), 'price_quantity_end' => vmRequest::getInt('price_quantity_end'));
$db = new ps_DB();
$db->buildQuery('INSERT', '#__{vm}_product_price', $fields);
if ($db->query() !== false) {
$_REQUEST['product_price_id'] = $db->last_insert_id();
$vmLogger->info($VM_LANG->_('VM_PRODUCT_PRICE_ADDED', false));
return true;
}
$vmLogger->err($VM_LANG->_('VM_PRODUCT_PRICE_ADDING_FAILED', false));
return false;
}
示例11: saveField
function saveField(&$d)
{
global $my, $mosConfig_live_site, $VM_LANG;
$db = new ps_DB();
if ($d['type'] == 'webaddress') {
$d['rows'] = $d['webaddresstypes'];
if (!($d['rows'] == 0 || $d['rows'] == 2)) {
$d['rows'] = 0;
}
}
$d['name'] = str_replace(" ", "", strtolower($d['name']));
if (!$this->validateOnSave($d)) {
return false;
}
// Prevent unpublishing and renaming of IMPORTANT Fields like "email", "username", "password",...
$fieldObj = $this->get($d['fieldid']);
if ($fieldObj !== false) {
if (in_array($fieldObj->f('name'), $this->getSkipFields())) {
$d['name'] = $fieldObj->f('name');
$d['required'] = $fieldObj->f('required');
$d['published'] = $fieldObj->f('published');
}
}
$fields = array('name' => vmGet($d, 'name'), 'title' => vmGet($d, 'title'), 'description' => vmGet($d, 'description'), 'type' => vmGet($d, 'type'), 'maxlength' => vmGet($d, 'maxlength'), 'size' => vmGet($d, 'size'), 'required' => vmGet($d, 'required'), 'ordering' => vmGet($d, 'ordering'), 'cols' => vmGet($d, 'cols'), 'rows' => vmGet($d, 'rows'), 'value' => vmGet($d, 'value'), 'default' => vmGet($d, 'default'), 'published' => vmGet($d, 'published'), 'registration' => vmGet($d, 'registration'), 'shipping' => vmGet($d, 'shipping'), 'account' => vmGet($d, 'account'), 'readonly' => vmGet($d, 'readonly'), 'calculated' => vmGet($d, 'calculated'), 'params' => vmGet($d, 'params'), 'vendor_id' => vmGet($_SESSION, 'ps_vendor_id', 1));
if (!empty($d['fieldid'])) {
// existing record
$db->buildQuery('UPDATE', '#__{vm}_userfield', $fields, 'WHERE `fieldid` =' . intval($d['fieldid']));
$db->query();
if ($d['type'] != 'delimiter') {
$this->changeColumn($d['name'], $d['cType'], 'update');
}
} else {
// add a new record
$sql = "SELECT MAX(ordering) as max FROM #__{vm}_userfield";
$db->query($sql);
$db->next_record();
$d['ordering'] = $db->f('max') + 1;
$db->buildQuery('INSERT', '#__{vm}_userfield', $fields);
$db->query();
$_REQUEST['fieldid'] = $db->last_insert_id();
if ($d['type'] != 'delimiter') {
$this->changeColumn($d['name'], $d['cType'], 'add');
}
}
$fieldNames = vmGet($d, 'vNames', array());
$fieldValues = vmGet($d, 'vValues', array());
$j = 1;
if (!empty($d['fieldid'])) {
$db->query("DELETE FROM #__{vm}_userfield_values" . " WHERE fieldid=" . (int) $d['fieldid'] . ' LIMIT 1');
} else {
$db->query("SELECT MAX(fieldid) as max FROM `#__{vm}_userfield`");
$maxID = $db->loadResult();
$d['fieldid'] = $maxID;
}
$n = count($fieldNames);
for ($i = 0; $i < $n; $i++) {
if (trim($fieldNames[$i]) != null || trim($fieldNames[$i]) != '') {
$fields = array('fieldid' => (int) $d['fieldid'], 'fieldtitle' => htmlspecialchars($fieldNames[$i]), 'fieldvalue' => htmlspecialchars($fieldValues[$i]), 'ordering' => $j);
$db->buildQuery('INSERT', '#__{vm}_userfield_values', $fields);
$db->query();
$j++;
}
}
$GLOBALS['vmLogger']->info($VM_LANG->_('VM_USERFIELD_SAVED'));
return true;
}
示例12: time
function rate_add(&$d)
{
$db = new ps_DB();
$timestamp = time();
if (!$this->validate_rate_add($d)) {
return False;
}
$country_str = "";
if (!empty($d["shipping_rate_country"])) {
for ($i = 0; $i < count($d["shipping_rate_country"]); $i++) {
if ($d["shipping_rate_country"][$i] != "") {
$country_str .= $d["shipping_rate_country"][$i] . ";";
}
}
chop($country_str, ";");
}
$fields = array('shipping_rate_name' => vmGet($d, 'shipping_rate_name'), 'shipping_rate_carrier_id' => (int) vmGet($d, 'shipping_rate_carrier_id'), 'shipping_rate_country' => $country_str, 'shipping_rate_zip_start' => vmGet($d, 'shipping_rate_zip_start'), 'shipping_rate_zip_end' => vmGet($d, 'shipping_rate_zip_end'), 'shipping_rate_weight_start' => vmGet($d, 'shipping_rate_weight_start'), 'shipping_rate_weight_end' => vmGet($d, 'shipping_rate_weight_end'), 'shipping_rate_value' => vmGet($d, 'shipping_rate_value'), 'shipping_rate_package_fee' => vmGet($d, 'shipping_rate_package_fee'), 'shipping_rate_currency_id' => vmGet($d, 'shipping_rate_currency_id'), 'shipping_rate_vat_id' => vmGet($d, 'shipping_rate_vat_id'), 'shipping_rate_list_order' => (int) vmGet($d, 'shipping_rate_list_order'));
$db->buildQuery('INSERT', '#__{vm}_shipping_rate', $fields);
$db->query();
$_REQUEST['shipping_rate_id'] = $db->last_insert_id();
return True;
}
示例13: array
function update_coupon(&$d)
{
global $vmLogger, $VM_LANG;
if (!$this->validate_update($d)) {
return false;
}
/* init the database */
$coupon_db = new ps_DB();
$fields = array('coupon_code' => vmGet($d, 'coupon_code'), 'percent_or_total' => strtolower($d['percent_or_total']) == 'percent' ? 'percent' : 'total', 'coupon_type' => strtolower($d['coupon_type']) == 'gift' ? 'gift' : 'permanent', 'coupon_value' => (double) $d['coupon_value']);
$coupon_db->buildQuery('UPDATE', '#__{vm}_coupons', $fields, 'WHERE coupon_id = ' . (int) $d['coupon_id']);
if ($coupon_db->query()) {
$_REQUEST['coupon_id'] = $coupon_db->last_insert_id();
$vmLogger->info($VM_LANG->_('VM_COUPON_UPDATED'));
return true;
}
return false;
}
示例14: addState
/**
* Adds a new state entry for a country specified by country_id
*
* @param array $d
* @return boolean
*/
function addState(&$d)
{
$db = new ps_DB();
if (empty($d['country_id'])) {
$GLOBALS['vmLogger']->err('No country was selected for this State');
return False;
}
$fields = array('state_name' => vmGet($d, 'state_name'), 'country_id' => vmRequest::getInt('country_id'), 'state_2_code' => vmGet($d, 'state_2_code'), 'state_3_code' => vmGet($d, 'state_3_code'));
$db->buildQuery('INSERT', '#__{vm}_state', $fields);
if ($db->query()) {
$GLOBALS['vmLogger']->info('The state has been added.');
$_REQUEST['state_id'] = $db->last_insert_id();
return True;
}
return false;
}
示例15: add
/**
* Creates a new category record and a category_xref record
* with the appropriate parent and child ids
* @author pablo
* @author soeren
*
* @param array $d
* @return mixed - int category_id on success, false on error
*/
function add(&$d)
{
global $vmLogger, $VM_LANG;
$ps_vendor_id = $_SESSION["ps_vendor_id"];
$db = new ps_DB();
$timestamp = time();
if ($this->validate_add($d)) {
if (!vmImageTools::process_images($d)) {
return false;
}
while (list($key, $value) = each($d)) {
if (!is_array($value)) {
$d[$key] = addslashes($value);
}
}
// Let's find out the last category in
// the level of the new category
$q = 'SELECT MAX(list_order) AS list_order FROM #__{vm}_category_xref,#__{vm}_category ';
$q .= 'WHERE category_parent_id=' . vmRequest::getInt('parent_category_id');
$q .= ' AND category_child_id=category_id';
$db->query($q);
$db->next_record();
$list_order = intval($db->f("list_order")) + 1;
if (empty($d["category_publish"])) {
$d["category_publish"] = "N";
}
$fields = array('vendor_id' => $ps_vendor_id, 'category_name' => vmGet($d, 'category_name'), 'category_publish' => vmGet($d, 'category_publish'), 'category_description' => vmGet($d, 'category_description', '', VMREQUEST_ALLOWHTML), 'category_browsepage' => vmGet($d, 'category_browsepage'), 'products_per_row' => vmRequest::getInt('products_per_row'), 'category_flypage' => vmGet($d, 'category_flypage'), 'category_thumb_image' => vmGet($d, 'category_thumb_image'), 'category_full_image' => vmGet($d, 'category_full_image'), 'cdate' => $timestamp, 'mdate' => $timestamp, 'list_order' => $list_order);
$db->buildQuery('INSERT', '#__{vm}_category', $fields);
$db->query();
$category_id = $_REQUEST['category_id'] = $db->last_insert_id();
$fields = array('category_parent_id' => (int) $d["parent_category_id"], 'category_child_id' => $category_id);
$db->buildQuery('INSERT', '#__{vm}_category_xref', $fields);
$db->query();
$vmLogger->info($VM_LANG->_('VM_PRODUCT_CATEGORY_ADDED') . ': "' . vmGet($d, 'category_name') . '"');
return true;
} else {
return False;
}
}