本文整理汇总了PHP中ps_DB::buildQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP ps_DB::buildQuery方法的具体用法?PHP ps_DB::buildQuery怎么用?PHP ps_DB::buildQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ps_DB
的用法示例。
在下文中一共展示了ps_DB::buildQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Updates a Vendor Category
*
* @param array $d
* @return boolean
*/
function update(&$d)
{
$db = new ps_DB();
if (!$this->validate_update($d)) {
return False;
}
$fields = array('vendor_category_name' => $d["vendor_category_name"], 'vendor_category_desc' => $d["vendor_category_desc"]);
$db->buildQuery('UPDATE', '#__{vm}_vendor_category', $fields, ' WHERE vendor_category_id=' . (int) $d["vendor_category_id"]);
$res = $db->query();
if ($res !== false) {
$GLOBALS['vmLogger']->info('The Vendor Category has been updated.');
return true;
}
$GLOBALS['vmLogger']->err('Failed to update the Vendor Category.');
return false;
}
示例2: substr
/**
* updates Parameter information
* @author Zdenek Dvorak
* @param array $d
* @return boolean
*/
function update_parameter(&$d)
{
$db = new ps_DB();
if ($this->validate_update_parameter($d)) {
if ($d["parameter_old_type"] == "B") {
// delete record and call add_parameter()
$q = "DELETE FROM #__{vm}_product_type_parameter WHERE product_type_id='" . $d["product_type_id"] . "' ";
$q .= "AND parameter_name='" . $db->getEscaped(vmGet($d, 'parameter_name')) . "'";
$db->setQuery($q);
$db->query();
return $this->add_parameter($d);
}
// added for custom parameter modification
// strips the trailing semi-colon from an values
if (';' == substr($d["parameter_values"], strlen($d["parameter_values"]) - 1, 1)) {
$d["parameter_values"] = substr($d["parameter_values"], 0, strlen($d["parameter_values"]) - 1);
}
if (empty($d["parameter_multiselect"])) {
$d["parameter_multiselect"] = "N";
}
// delete "\n" from field parameter_description
$d["parameter_description"] = str_replace("\r\n", "", $d["parameter_description"]);
$d["parameter_description"] = str_replace("\n", "", $d["parameter_description"]);
$fields = array('parameter_name' => vmGet($d, 'parameter_name'), 'parameter_label' => vmGet($d, 'parameter_label'), 'parameter_description' => vmGet($d, 'parameter_description'), 'parameter_list_order' => vmRequest::getInt('list_order'), 'parameter_type' => vmGet($d, 'parameter_type'), 'parameter_values' => vmGet($d, 'parameter_values'), 'parameter_multiselect' => vmGet($d, 'parameter_multiselect'), 'parameter_default' => vmGet($d, 'parameter_default'), 'parameter_unit' => vmGet($d, 'parameter_unit'));
$db->buildQuery('UPDATE', '#__{vm}_product_type_parameter', $fields, "WHERE `product_type_id`='" . $d["product_type_id"] . "' AND `parameter_name`='" . $db->getEscaped(vmGet($d, 'parameter_old_name')) . "'");
$db->query();
/* Re-Order the Parameter table IF the list_order has been changed */
if (intval($d['list_order']) != intval($d['currentpos'])) {
$dbu = new ps_DB();
/* Moved UP in the list order */
if (intval($d['list_order']) < intval($d['currentpos'])) {
$q = "SELECT product_type_id,parameter_name FROM #__{vm}_product_type_parameter WHERE ";
$q .= "product_type_id=' " . $d["product_type_id"];
$q .= "' AND parameter_name <> '" . $db->getEscaped(vmGet($d, 'parameter_name'));
$q .= "' AND parameter_list_order >= '" . intval($d["list_order"]) . "'";
$db->query($q);
while ($db->next_record()) {
$dbu->query("UPDATE #__{vm}_product_type_parameter SET parameter_list_order=parameter_list_order+1 WHERE product_type_id='" . $db->f("product_type_id") . "' AND parameter_name='" . $db->f("parameter_name") . "'");
}
} else {
$q = "SELECT product_type_id,parameter_name FROM #__{vm}_product_type_parameter WHERE ";
$q .= "product_type_id='" . $d["product_type_id"];
$q .= "' AND parameter_name <> '" . $db->getEscaped(vmGet($d, 'parameter_name'));
$q .= "' AND parameter_list_order > '" . intval($d["currentpos"]);
$q .= "' AND parameter_list_order <= '" . intval($d["list_order"]) . "'";
$db->query($q);
while ($db->next_record()) {
$dbu->query("UPDATE #__{vm}_product_type_parameter SET parameter_list_order=parameter_list_order-1 WHERE product_type_id='" . $db->f("product_type_id") . "' AND parameter_name='" . $db->f("parameter_name") . "'");
}
}
}
/* END Re-Ordering */
if ($d["parameter_type"] != "B") {
// != Break Line
// Delete old index
$q = "ALTER TABLE `#__{vm}_product_type_";
$q .= $d["product_type_id"] . "` DROP INDEX `idx_product_type_" . $d["product_type_id"] . "_";
$q .= $db->getEscaped(vmGet($d, 'parameter_old_name')) . "`;";
$db->setQuery($q);
$db->query();
// Update column in table product_type_<id>
$q = "ALTER TABLE `#__{vm}_product_type_";
$q .= $d["product_type_id"] . "` CHANGE `";
$q .= $db->getEscaped(vmGet($d, 'parameter_old_name')) . "` `";
$q .= $db->getEscaped(vmGet($d, 'parameter_name')) . "` ";
switch ($d["parameter_type"]) {
case "I":
$q .= "int(11) ";
break;
// Integer
// Integer
case "T":
$q .= "text ";
break;
// Text
// Text
case "S":
$q .= "varchar(255) ";
break;
// Short Text
// Short Text
case "F":
$q .= "float ";
break;
// Float
// Float
case "C":
$q .= "char(1) ";
break;
// Char
// Char
case "D":
$q .= "datetime ";
break;
//.........这里部分代码省略.........
示例3: update
/**
* Updates a Vendor (and the Store) Record
*
* @param array $d
* @return boolean
*/
function update(&$d)
{
global $vendor_currency, $VM_LANG;
$db = new ps_DB();
$timestamp = time();
if (!$this->validate_update($d)) {
return False;
}
if (!vmImageTools::process_images($d)) {
return false;
}
foreach ($d as $key => $value) {
if (!is_array($value)) {
$d[$key] = addslashes($value);
}
}
$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_thumb_image' => $d["vendor_thumb_image"], 'vendor_full_image' => $d["vendor_full_image"], 'vendor_currency' => $d["vendor_currency"], 'vendor_url' => $d["vendor_url"], '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']);
if (!empty($d["vendor_category_id"])) {
$fields['vendor_category_id'] = $d["vendor_category_id"];
}
if (!empty($d["vendor_image_path"])) {
$fields['vendor_image_path'] = $d["vendor_image_path"];
}
$db->buildQuery('UPDATE', '#__{vm}_vendor', $fields, 'WHERE vendor_id = ' . $d["vendor_id"]);
$db->query();
if ($d['vendor_id'] == 1) {
$GLOBALS['vmLogger']->info($VM_LANG->_('VM_STORE_UPDATED'));
} else {
$GLOBALS['vmLogger']->info($VM_LANG->_('VM_VENDOR_UPDATED'));
}
return True;
}
示例4: update
/**
* update export module
* @param array
* @return bool
* @author Manfred Dennerlein
*/
function update(&$d)
{
global $vmLogger, $VM_LANG;
$db = new ps_DB();
$ps_vendor_id = $_SESSION['ps_vendor_id'];
$timestamp = time();
if (!$this->validate_update($d)) {
return False;
}
if (!empty($d['export_class'])) {
$export_class = basename($d['export_class']);
if (include_once CLASSPATH . 'export/' . $export_class . '.php') {
$_EXPORT = new $export_class();
}
} else {
include_once CLASSPATH . 'export/ps_xmlexport.php';
$_EXPORT = new ps_xmlexport();
}
if ($_EXPORT->configfile_writeable()) {
$_EXPORT->write_configuration($d);
$vmLogger->info($VM_LANG->_('VM_CONFIGURATION_CHANGE_SUCCESS', false));
} else {
$vmLogger->err(sprintf($VM_LANG->_('VM_CONFIGURATION_CHANGE_FAILURE', false), CLASSPATH . "export/" . $_EXPORT->classname . ".cfg.php"));
return false;
}
$fields = array('export_enabled' => $d['export_enabled'], 'export_config' => $d['export_config']);
if (!$d['iscore']) {
$fields['export_name'] = $d['export_name'];
$fields['export_desc'] = $d['export_desc'];
$fields['export_class'] = $d['export_class'];
}
$db->buildQuery('INSERT', '#__{vm}_export', $fields, 'WHERE export_id=' . (int) $d['export_id'] . " AND vendor_id='{$ps_vendor_id}'");
return $db->query() !== false;
}
示例5: update
/**
* Updates an Order Status
*
* @param array $d
* @return boolean
*/
function update(&$d)
{
global $VM_LANG;
$db = new ps_DB();
$ps_vendor_id = $_SESSION["ps_vendor_id"];
if (!$this->validate_update($d)) {
return False;
}
$fields = array('order_status_code' => vmGet($d, 'order_status_code'), 'order_status_name' => vmGet($d, 'order_status_name'), 'order_status_description' => vmGet($d, 'order_status_description'), 'list_order' => vmRequest::getInt('list_order'));
$db->buildQuery('UPDATE', $this->_table_name, $fields, "WHERE order_status_id=" . (int) $d["order_status_id"] . " AND vendor_id={$ps_vendor_id}");
if ($db->query() !== false) {
$GLOBALS['vmLogger']->info($VM_LANG->_('VM_ORDERSTATUS_UPDATED'));
return true;
}
return false;
}
示例6: update
/**
* Updates a given Credit Card Record
*
* @param array $d
* @return boolean
*/
function update(&$d)
{
global $VM_LANG;
$db = new ps_DB();
$timestamp = time();
if (!$this->validate_update($d)) {
$d["error"] = $this->error;
return False;
}
$fields = array('vendor_id' => $_SESSION["ps_vendor_id"], 'creditcard_name' => vmGet($d, 'creditcard_name'), 'creditcard_code' => vmGet($d, 'creditcard_code'));
$db->buildQuery('UPDATE', '#__{vm}_creditcard', $fields, 'WHERE creditcard_id=' . (int) $d["creditcard_id"]);
if ($db->query()) {
$GLOBALS['vmLogger']->info($VM_LANG->_('VM_CREDITCARD_UPDATED'));
$_REQUEST['creditcard_id'] = $db->last_insert_id();
return true;
}
return false;
}
示例7: update
/**
* Updates an attribute record
*
* @param array $d
* @return boolean True when successful, false when not
*/
function update(&$d)
{
global $VM_LANG;
if (!$this->validate($d)) {
return false;
}
$db = new ps_DB();
$fields = array('attribute_name' => $d["attribute_name"], 'attribute_list' => $d["attribute_list"]);
$db->buildQuery('UPDATE', '#__{vm}_product_attribute_sku', $fields, "WHERE product_id='" . (int) $d["product_id"] . "' AND attribute_name='" . $db->getEscaped($d["old_attribute_name"]) . "'");
if ($db->query() === false) {
$GLOBALS['vmLogger']->err($VM_LANG->_('VM_PRODUCT_ATTRIBUTE_ERR_UPDATING'));
return false;
}
if ($d["old_attribute_name"] != $d["attribute_name"]) {
$ps_product = new ps_product();
$child_pid = $ps_product->get_child_product_ids($d["product_id"]);
for ($i = 0; $i < count($child_pid); $i++) {
$fields = array('attribute_name' => $d["attribute_name"]);
$db->buildQuery('UPDATE', '#__{vm}_product_attribute', $fields, "WHERE product_id='" . $child_pid[$i] . "' AND attribute_name='" . $db->getEscaped($d["old_attribute_name"]) . "' ");
$db->query();
}
}
$GLOBALS['vmLogger']->info($VM_LANG->_('VM_PRODUCT_ATTRIBUTE_UPDATED'));
return true;
}
示例8: update
/**
* updates discount information
*
* @param array $d
* @return boolean
*/
function update(&$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"] = "";
}
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"] = "";
}
if (!$this->validate_update($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('UPDATE', '#__{vm}_product_discount', $fields, 'WHERE discount_id=' . (int) $d["discount_id"]);
$db->query();
$GLOBALS['vmLogger']->info($VM_LANG->_('VM_PRODUCT_DISCOUNT_UPDATED'));
return True;
}
示例9: while
/**
* Sorts ALL categories in the store alphabetically
* This is VERY recursive...
* @author soeren
*
* @param int $category_id
* @param int $level
*/
function sort_alphabetically($category_id = 0, $level = 0)
{
static $ibg = 0;
$ps_vendor_id = $_SESSION["ps_vendor_id"];
$db = new ps_DB();
$level++;
$q = "SELECT `c`.`category_id`, `cx`.`category_child_id`, `cx`.`category_parent_id` as cpid \n\t\t\t\tFROM `#__{vm}_category` as `c`,`#__{vm}_category_xref` as `cx` ";
$q .= "WHERE `c`.`category_id`=`cx`.`category_child_id` AND `cx`.`category_parent_id`={$category_id} ";
$q .= "AND `c`.`vendor_id`={$ps_vendor_id} ";
$q .= "ORDER BY `category_name` ASC ";
$db->query($q);
$i = 1;
while ($db->next_record()) {
// Update the categories in this level
$fields = array('category_list' => $i);
$dbu = new ps_DB();
$dbu->buildQuery('UPDATE', '#__{vm}_category_xref', $fields, 'WHERE `category_child_id`=' . $db->f('category_child_id'));
$dbu->query();
$fields = array('list_order' => $i);
$dbu->buildQuery('UPDATE', '#__{vm}_category', $fields, 'WHERE `category_id`=' . $db->f('category_child_id'));
$dbu->query();
// Traverse the tree down
$this->sort_alphabetically($db->f('category_child_id'), $level);
$i++;
}
}
示例10: update
/**
* updates manufacturer information
*
* @param array $d
* @return boolean
*/
function update(&$d)
{
global $VM_LANG;
$db = new ps_DB();
if (!$this->validate_update($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('UPDATE', '#__{vm}_manufacturer', $fields, 'WHERE manufacturer_id=' . (int) $d["manufacturer_id"]);
if ($db->query()) {
$GLOBALS['vmLogger']->info($VM_LANG->_('VM_MANUF_UPDATED'));
return true;
}
return false;
}
示例11: setUserInfo
/**
* Inserts or Updates the user information
*
* @param array $user_info
* @param int $user_id
*/
function setUserInfo($user_info, $user_id = 0)
{
$db = new ps_DB();
if (empty($user_id)) {
// INSERT NEW USER
$db->buildQuery('INSERT', '#__{vm}_user_info', $user_info);
// Run the query now!
$db->query();
} else {
// UPDATE EXISTING USER
$db->buildQuery('UPDATE', '#__{vm}_user_info', $user_info, 'WHERE `user_id`=' . $user_id);
// Run the query now!
$db->query();
}
}
示例12: update
/**
* Updates a product price
*
* @param array $d
* @return boolean
*/
function update(&$d)
{
global $vmLogger, $VM_LANG;
if (!$this->validate($d)) {
return false;
}
if ($d["product_price"] === '') {
return $this->delete($d);
}
$timestamp = time();
$db = new ps_DB();
if (empty($d["product_price_vdate"])) {
$d["product_price_vdate"] = '';
}
if (empty($d["product_price_edate"])) {
$d["product_price_edate"] = '';
}
$fields = array('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'), 'mdate' => $timestamp, 'price_quantity_start' => vmRequest::getInt('price_quantity_start'), 'price_quantity_end' => vmRequest::getInt('price_quantity_end'));
$db = new ps_DB();
$db->buildQuery('UPDATE', '#__{vm}_product_price', $fields, 'WHERE product_price_id=' . (int) $d["product_price_id"]);
if ($db->query() !== false) {
$vmLogger->info($VM_LANG->_('VM_PRODUCT_PRICE_UPDATED', false));
return true;
}
$vmLogger->err($VM_LANG->_('VM_PRODUCT_PRICE_UPDATING_FAILED', false));
return false;
}
示例13: changeOrdering
function changeOrdering($table, $name, $k, $entity_name, $where = '', $table2_name = '')
{
global $db, $vmLogger;
if (strtolower(@$_REQUEST['task']) == 'saveorder') {
$i = 0;
foreach ($_REQUEST[$k] as $item) {
$sql = "UPDATE `{$table}` SET `{$name}` =" . intval($_REQUEST['order'][$i]) . " WHERE `{$k}`=" . intval($item);
$sql .= $where ? "\n\tAND {$where}" : '';
$db->query($sql);
$i++;
}
$this->fixOrdering($table, $name, $k, $where);
} elseif (strtolower(@$_REQUEST['task']) == 'sort_alphabetically') {
$select_where = $where;
$q = 'SELECT `' . $name . '`, `' . $table . '`.`' . $k . '`, `' . $entity_name . '` FROM `' . $table . '`';
if ($table2_name != '') {
$q .= $table2_name != '' ? ',`' . $table2_name . '`' : '';
$select_where = $where . "\n AND `{$table}`.`{$k}`=`{$table2_name}`.`{$k}`";
}
$q .= ' WHERE ' . $select_where . ' ORDER BY `' . $entity_name . '`';
$db->query($q);
$i = 1;
$dbu = new ps_DB();
while ($db->next_record()) {
$fields = array($name => $i);
$where_query = "WHERE `{$k}`=" . intval($db->f($k));
$where_query .= $where ? "\n\tAND {$where}" : '';
$dbu->buildQuery('UPDATE', $table, $fields, $where_query);
//echo $dbu->_sql;
$dbu->query();
$i++;
}
} else {
$item = intval($_REQUEST[$k][0]);
$db->query("SELECT `{$name}` FROM `{$table}` WHERE `{$k}`={$item}");
$db->next_record();
$this->{$name} = $db->f($name);
$this->{$k} = $item;
$sql = "SELECT {$k}, {$name} FROM `{$table}`";
if ($_REQUEST['task'] == 'orderup') {
$sql .= "\n WHERE `{$name}` < " . intval($this->{$name});
$sql .= $where ? "\n\tAND {$where}" : '';
$sql .= "\n ORDER BY `{$name}` DESC";
$sql .= "\n LIMIT 1";
} elseif ($_REQUEST['task'] == 'orderdown') {
$sql .= "\n WHERE `{$name}` > " . intval($this->{$name});
$sql .= $where ? "\n\tAND {$where}" : '';
$sql .= "\n ORDER BY `{$name}`";
$sql .= "\n LIMIT 1";
} else {
$sql .= "\nWHERE `{$name}` = " . intval($this->{$name});
$sql .= $where ? "\n AND {$where}" : '';
$sql .= "\n ORDER BY `{$name}`";
$sql .= "\n LIMIT 1";
}
$db->query($sql);
//echo 'A: ' . $db->_database->_sql;
if ($db->next_record()) {
$field_value = $db->f($name);
$field_key_value = $db->f($k);
$query = "UPDATE `{$table}`" . "\n SET `{$name}` = '" . $field_value . "'" . "\n WHERE `{$k}` = '" . $this->{$k} . "'";
$db->setQuery($query);
if (!$db->query()) {
$err = $db->getErrorMsg();
//die( $err );
}
//echo 'B: ' . $db->getQuery();
$query = "UPDATE `{$table}`" . "\n SET `{$name}` = '" . $this->{$name} . "'" . "\n WHERE `{$k}` = '" . $field_key_value . "'";
$db->setQuery($query);
//echo 'C: ' . $db->getQuery();
if (!$db->query()) {
$err = $db->getErrorMsg();
//die( $err );
}
$this->{$name} = $field_value;
} else {
$query = "UPDATE `{$table}`" . "\n SET `{$name}` = '" . $this->{$name} . "'" . "\n WHERE `{$k}`= '" . $this->{$k} . "'";
$db->setQuery($query);
//echo 'D: ' . $db->getQuery();
if (!$db->query()) {
$err = $db->getErrorMsg();
//die( $err );
}
}
}
return true;
}
示例14: foreach
function update_permissions(&$d)
{
$db = new ps_DB();
$i = 0;
foreach ($d['module_perms'] as $module) {
$modules = implode(',', array_keys($module));
$module_id = (int) $d['module_id'][$i];
$db->buildQuery('UPDATE', '#__{vm}_module', array('module_perms' => $modules), 'WHERE module_id=' . $module_id);
$db->query();
$i++;
}
return true;
}
示例15: 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;
}