本文整理汇总了PHP中oseDB::getDBFields方法的典型用法代码示例。如果您正苦于以下问题:PHP oseDB::getDBFields方法的具体用法?PHP oseDB::getDBFields怎么用?PHP oseDB::getDBFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oseDB
的用法示例。
在下文中一共展示了oseDB::getDBFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public static function save()
{
$post = JRequest::get('post');
if (!empty($post['firstname'])) {
$post['bill_firstname'] = $post['firstname'];
}
if (!empty($post['lastname'])) {
$post['bill_lastname'] = $post['lastname'];
}
$member_id = JRequest::getInt('member_id', 0);
$billinfo = array();
foreach ($post as $key => $value) {
if (strstr($key, 'bill_')) {
$billKey = str_replace('bill_', '', $key);
$billinfo[$billKey] = $value;
}
}
//oseExit($billinfo);
$db = oseDB::instance();
$query = " SELECT count(*) FROM `#__osemsc_billinginfo` WHERE user_id='{$member_id}'";
$db->setQuery($query);
$num = $db->loadResult();
$my = JFactory::getUser();
if (empty($num)) {
$keys = array_keys($billinfo);
$keys = '`' . implode('`,`', $keys) . '`';
$fields = oseDB::getDBFields('#__osemsc_billinginfo');
foreach ($billinfo as $key => $value) {
if (!isset($fields['#__osemsc_billinginfo'][$key])) {
if ($my->get('gid') == 24 || $my->get('gid') == 25) {
$query = "ALTER TABLE `#__osemsc_billinginfo` ADD `{$key}` TEXT NULL DEFAULT NULL";
$db->setQuery($query);
if (!oseDB::query()) {
$result['success'] = false;
$result['title'] = JText::_('ERROR');
$result['content'] = JText::_('FAIL_SAVING_OSEMSC_USER_INFO');
}
} else {
unset($billinfo[$key]);
}
}
}
foreach ($billinfo as $key => $value) {
$billinfo[$key] = !empty($value) ? $db->Quote($value) : null;
}
$values = implode(',', $billinfo);
$query = "INSERT INTO `#__osemsc_billinginfo` (`user_id`,{$keys}) VALUES ('{$member_id}',{$values});";
} else {
foreach ($billinfo as $key => $value) {
$billinfo[$key] = "`{$key}`=" . $db->Quote($value);
}
$values = implode(',', $billinfo);
$query = " UPDATE `#__osemsc_billinginfo` SET {$values}" . " WHERE `user_id` ={$member_id}";
}
//echo $query;exit;
$db->setQuery($query);
if (!oseDB::query()) {
$result = array();
$result['success'] = true;
$result['title'] = JText::_('DONE');
$result['content'] = JText::_('FAIL_SAVING_OSEMSC_USER_INFO');
} else {
$result = array();
$result['success'] = true;
$result['title'] = JText::_('DONE');
$result['content'] = JText::_('SAVED_USER_BILLING_INFO');
}
return $result;
}