本文整理汇总了PHP中MySQL::AutoInsertUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP MySQL::AutoInsertUpdate方法的具体用法?PHP MySQL::AutoInsertUpdate怎么用?PHP MySQL::AutoInsertUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySQL
的用法示例。
在下文中一共展示了MySQL::AutoInsertUpdate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user_set_preferences
/**
* Save one or more preferences for a user. If no user ID is given the current user is used.
* The array has to assign every preference key a value to store.
* Example: array ( 'setting1' => 'value1', 'setting2' => 'value2');
*
* A prefix can be specified, which will be prepended to every preference key.
*
* @param array $data key/value pairs to store
* @param string $prefix prefix for all preferences
* @param integer $userId (optional) id of another user than the current
* @return boolean true on success, false on failure
* @author sl
*/
public function user_set_preferences(array $data, $prefix = '', $userId = null)
{
if ($userId === null) {
$userId = $this->kga['user']['userID'];
}
if (!$this->conn->TransactionBegin()) {
$this->logLastError('user_set_preferences');
return false;
}
$table = $this->kga['server_prefix'] . "preferences";
$filter['userID'] = MySQL::SQLValue($userId, MySQL::SQLVALUE_NUMBER);
$values['userID'] = $filter['userID'];
foreach ($data as $key => $value) {
$values['option'] = MySQL::SQLValue($prefix . $key);
$values['value'] = MySQL::SQLValue($value);
$filter['option'] = $values['option'];
$this->conn->AutoInsertUpdate($table, $values, $filter);
}
return $this->conn->TransactionEnd();
}
示例2: admin_cp_lostpw
/** Quên mật khẩu admin cp */
function admin_cp_lostpw()
{
global $hmuser;
$hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
hook_action('admin_cp_lostpw');
$user_email = hm_post('email');
$reset_password = hm_post('reset-password');
if (is_numeric($reset_password)) {
$tableName = DB_PREFIX . "users";
$whereArray = array('user_email' => MySQL::SQLValue($user_email));
$hmdb->SelectRows($tableName, $whereArray);
if ($hmdb->HasRecords()) {
$row = $hmdb->Row();
$user_id = $row->id;
$user_login = $row->user_login;
$lostpw_key = generateRandomString(10);
$values["name"] = MySQL::SQLValue('lostpw_key');
$values["val"] = MySQL::SQLValue($lostpw_key);
$values["object_id"] = MySQL::SQLValue($user_id, MySQL::SQLVALUE_NUMBER);
$values["object_type"] = MySQL::SQLValue('user');
$whereArray = array('object_id' => MySQL::SQLValue($user_id, MySQL::SQLVALUE_NUMBER), 'object_type' => MySQL::SQLValue('user'), 'name' => MySQL::SQLValue('lostpw_key'));
$tableName = DB_PREFIX . "field";
$hmdb->AutoInsertUpdate($tableName, $values, $whereArray);
$newpw_url = SITE_URL . FOLDER_PATH . HM_ADMINCP_DIR . '?run=login.php&action=newpw&key=' . $lostpw_key;
$mail_content = 'Một ai đó đã yêu cầu đặt lại mật khẩu cho tài khoản ' . $user_login . ', nếu bạn đã làm điều đó vui lòng <a href="' . $newpw_url . '">bấm vào đây để đặt mật khẩu mới</a>';
//send mail
$send_mail = mail($user_email, _('Lấy lại mật khẩu:') . SITE_URL, $message);
if ($send_mail) {
return json_encode(array('status' => 'success', 'mes' => _('Mật khẩu mới đã được gửi về email')));
} else {
return json_encode(array('status' => 'error', 'mes' => _('Máy chủ không thể gửi mail xác nhận đổi mật khẩu, vui lòng báo với chủ trang web')));
}
} else {
return json_encode(array('status' => 'error', 'mes' => _('Email này không khớp với bất kì tài khoản nào')));
}
}
}
示例3: disable_plugin
/** Active / Deactive plugin */
function disable_plugin($status, $plugin_key = FALSE)
{
$hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
if ($plugin_key == FALSE) {
$plugin_key = hm_post('plugin');
}
if (is_dir(BASEPATH . HM_PLUGIN_DIR . '/' . $plugin_key) and is_file(BASEPATH . HM_PLUGIN_DIR . '/' . $plugin_key . '/' . $plugin_key . '.php')) {
$tableName = DB_PREFIX . 'plugin';
$values["active"] = MySQL::SQLValue($status);
$values["key"] = MySQL::SQLValue($plugin_key);
$whereArray = array('key' => MySQL::SQLValue($plugin_key));
$hmdb->AutoInsertUpdate($tableName, $values, $whereArray);
$mes = NULL;
if ($status == '1') {
$mes = $plugin_key . ' active';
} elseif ($status == '0') {
$mes = $plugin_key . ' deactive';
}
$args = array('status' => 'success', 'mes' => $mes);
return json_encode($args);
}
}
示例4: ajax_add_user
/** Load template user box */
function ajax_add_user($args = array())
{
global $hmuser;
$hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
hook_action('ajax_add_user');
if (isset($args['id_update'])) {
$id_update = $args['id_update'];
} else {
$id_update = NULL;
}
$user_login = hm_post('user_login');
$password = hm_post('password');
$password2 = hm_post('password2');
$nicename = hm_post('nicename');
$user_email = hm_post('user_email');
$userrole = hm_post('userrole');
$user_group = hm_post('user_group', 0);
$salt = rand(100000, 999999);
$user_activation_key = '0';
if ($password != $password2) {
return json_encode(array('status' => 'error', 'mes' => _('Hai mật khẩu nhập vào không khớp')));
hm_exit();
}
$tableName = DB_PREFIX . "users";
/** check trùng user login */
if (!is_numeric($id_update)) {
$whereArray = array('user_login' => MySQL::SQLValue($user_login));
$hmdb->SelectRows($tableName, $whereArray);
if ($hmdb->HasRecords()) {
return json_encode(array('status' => 'error', 'mes' => _('Tài khoản này đã tồn tại')));
hm_exit();
}
}
$password_encode = hm_encode_str(md5($password . $salt));
/** Thêm tài khoản */
$values["user_login"] = MySQL::SQLValue($user_login);
$values["user_nicename"] = MySQL::SQLValue($nicename);
$values["user_email"] = MySQL::SQLValue($user_email);
$values["user_activation_key"] = MySQL::SQLValue($user_activation_key);
$values["user_role"] = MySQL::SQLValue($userrole);
$values["user_group"] = MySQL::SQLValue($user_group);
if (is_numeric($id_update)) {
if ($password != '') {
$values["user_pass"] = MySQL::SQLValue($password_encode);
$values["salt"] = MySQL::SQLValue($salt);
}
$whereArray = array('id' => $id_update);
$hmdb->AutoInsertUpdate($tableName, $values, $whereArray);
$insert_id = $id_update;
} else {
$values["user_pass"] = MySQL::SQLValue($password_encode);
$values["salt"] = MySQL::SQLValue($salt);
$insert_id = $hmdb->InsertRow($tableName, $values);
}
/** Lưu user field */
foreach ($_POST as $post_key => $post_val) {
if (is_numeric($insert_id)) {
if (is_array($post_val)) {
$post_val = json_encode($post_val);
}
$tableName = DB_PREFIX . 'field';
if ($post_key != 'password' and $post_key != 'password2') {
$values["name"] = MySQL::SQLValue($post_key);
$values["val"] = MySQL::SQLValue($post_val);
$values["object_id"] = MySQL::SQLValue($insert_id, MySQL::SQLVALUE_NUMBER);
$values["object_type"] = MySQL::SQLValue('user');
if (is_numeric($id_update)) {
$whereArray = array('object_id' => MySQL::SQLValue($id_update, MySQL::SQLVALUE_NUMBER), 'object_type' => MySQL::SQLValue('user'), 'name' => MySQL::SQLValue($post_key));
$hmdb->AutoInsertUpdate($tableName, $values, $whereArray);
} else {
$hmdb->InsertRow($tableName, $values);
}
}
unset($values);
}
}
if (is_numeric($id_update)) {
return json_encode(array('status' => 'updated', 'mes' => _('Đã sửa thông tin tài khoản : ' . $user_login)));
} else {
return json_encode(array('status' => 'success', 'mes' => _('Đã thêm tài khoản : ' . $user_login)));
}
}
示例5: content_ajax_add
function content_ajax_add($args = array())
{
global $hmcontent;
$hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
hook_action('content_ajax_add');
if (isset($args['content_key'])) {
$key = $args['content_key'];
} else {
$key = NULL;
}
if (isset($args['id_update'])) {
$id_update = $args['id_update'];
} else {
$id_update = NULL;
}
if (isset($args['parent'])) {
$parent = $args['parent'];
} else {
$parent = 0;
}
if (isset($args['status'])) {
$status = $args['status'];
} else {
$status = 'public';
}
$con = $hmcontent->hmcontent;
if (isset($_POST['taxonomy'])) {
$method_post_taxonomy = $_POST['taxonomy'];
} else {
$method_post_taxonomy = array();
}
if ($key != NULL and isset($con[$key])) {
$this_con = $con[$key];
foreach ($_POST as $post_key => $post_val) {
$primary = $this_con['content_field']['primary_name_field']['name'];
/** input này được dùng làm khóa tên chính */
if ($post_key == $primary) {
$con_name = $post_val;
if (isset($_POST['slug_of_' . $post_key])) {
if (is_numeric($id_update)) {
$con_slug = $_POST['slug_of_' . $post_key];
$con_slug = str_replace('#', '-', $con_slug);
} else {
$con_slug = add_request_uri_custom($_POST['slug_of_' . $post_key]);
}
} else {
switch ($_POST['accented_of_' . $post_key]) {
case 'true':
if (is_numeric($id_update)) {
$con_slug = sanitize_title_with_accented($post_val);
} else {
$con_slug = add_request_uri_with_accented($post_val);
}
break;
case 'false':
if (is_numeric($id_update)) {
$con_slug = sanitize_title($post_val);
} else {
$con_slug = add_request_uri($post_val);
}
break;
default:
if (is_numeric($id_update)) {
$con_slug = sanitize_title($post_val);
} else {
$con_slug = add_request_uri($post_val);
}
}
}
/** lưu content vào database */
$tableName = DB_PREFIX . 'content';
$values["name"] = MySQL::SQLValue($con_name);
$values["slug"] = MySQL::SQLValue($con_slug);
$values["key"] = MySQL::SQLValue($key);
$values["status"] = MySQL::SQLValue($status);
$values["parent"] = MySQL::SQLValue($parent);
if (is_numeric($id_update)) {
$args_con = content_data_by_id($id_update);
$key = $args_con['content']->key;
$status = $args_con['content']->status;
$parent = $args_con['content']->parent;
$values["key"] = MySQL::SQLValue($key);
$values["status"] = MySQL::SQLValue($status);
$values["parent"] = MySQL::SQLValue($parent);
$whereArray = array('id' => $id_update);
$hmdb->AutoInsertUpdate($tableName, $values, $whereArray);
$insert_id = $id_update;
up_date_request_uri_object($con_slug, $insert_id, 'content', 'has_object');
} else {
$insert_id = $hmdb->InsertRow($tableName, $values);
up_date_request_uri_object($con_slug, $insert_id, 'content', 'null_object');
}
unset($values);
}
}
foreach ($_POST as $post_key => $post_val) {
/** lưu content field vào data */
if (is_numeric($insert_id)) {
if (is_array($post_val)) {
$post_val = json_encode($post_val);
//.........这里部分代码省略.........
示例6: taxonomy_ajax_add
function taxonomy_ajax_add($key, $id_update = NULL)
{
global $hmtaxonomy;
$hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
hook_action('taxonomy_ajax_add');
$tax = $hmtaxonomy->hmtaxonomy;
if (isset($tax[$key])) {
$this_tax = $tax[$key];
foreach ($_POST as $post_key => $post_val) {
$primary = $this_tax['taxonomy_field']['primary_name_field']['name'];
/** input này được dùng làm khóa tên chính */
if ($post_key == $primary) {
$tax_name = $post_val;
$parent = hm_post('parent');
if (!is_numeric($parent)) {
$parent = 0;
}
if ($parent == $id_update) {
$parent = 0;
}
if (isset($_POST['slug_of_' . $post_key])) {
if (is_numeric($id_update)) {
$tax_slug = $_POST['slug_of_' . $post_key];
} else {
$tax_slug = add_request_uri_custom($_POST['slug_of_' . $post_key]);
}
} else {
switch ($_POST['accented_of_' . $post_key]) {
case 'true':
if (is_numeric($id_update)) {
$tax_slug = sanitize_title_with_accented($post_val);
} else {
$tax_slug = add_request_uri_with_accented($post_val);
}
break;
case 'false':
if (is_numeric($id_update)) {
$tax_slug = sanitize_title($post_val);
} else {
$tax_slug = add_request_uri($post_val);
}
break;
default:
if (is_numeric($id_update)) {
$tax_slug = sanitize_title($post_val);
} else {
$tax_slug = add_request_uri($post_val);
}
}
}
/** lưu taxonomy vào data base */
$tableName = DB_PREFIX . 'taxonomy';
$values["name"] = MySQL::SQLValue($tax_name);
$values["slug"] = MySQL::SQLValue($tax_slug);
$values["key"] = MySQL::SQLValue($key);
$values["parent"] = MySQL::SQLValue($parent);
$values["status"] = MySQL::SQLValue('public');
if (is_numeric($id_update)) {
unset($values["status"]);
$whereArray = array('id' => $id_update);
$hmdb->AutoInsertUpdate($tableName, $values, $whereArray);
$insert_id = $id_update;
up_date_request_uri_object($tax_slug, $insert_id, 'taxonomy', 'has_object');
} else {
$insert_id = $hmdb->InsertRow($tableName, $values);
up_date_request_uri_object($tax_slug, $insert_id, 'taxonomy', 'null_object');
}
$latest_array = array('id' => $insert_id, 'name' => $tax_name, 'slug' => $tax_slug, 'key' => $key, 'parent' => $parent);
unset($values);
}
}
foreach ($_POST as $post_key => $post_val) {
/** lưu taxonomy field vào data */
if (is_numeric($insert_id)) {
$tableName = DB_PREFIX . 'field';
$values["name"] = MySQL::SQLValue($post_key);
$values["val"] = MySQL::SQLValue($post_val);
$values["object_id"] = MySQL::SQLValue($insert_id, MySQL::SQLVALUE_NUMBER);
$values["object_type"] = MySQL::SQLValue('taxonomy');
if (is_numeric($id_update)) {
$whereArray = array('object_id' => MySQL::SQLValue($id_update, MySQL::SQLVALUE_NUMBER), 'object_type' => MySQL::SQLValue('taxonomy'), 'name' => MySQL::SQLValue($post_key));
$hmdb->AutoInsertUpdate($tableName, $values, $whereArray);
} else {
$hmdb->InsertRow($tableName, $values);
}
unset($values);
}
}
/** show table */
$status = hm_get('status', 'public');
$perpage = hm_get('perpage', '30');
$return_array = taxonomy_show_data($key, $status, $perpage, false);
$return_array['latest'] = $latest_array;
return json_encode($return_array, true);
}
}