Cloudlog/application/models/User_options_model.php

28 wiersze
975 B
PHP
Czysty Zwykły widok Historia

2023-08-18 12:49:12 +00:00
<?php
2023-08-18 14:42:04 +00:00
class User_options_model extends CI_Model {
2023-08-18 12:49:12 +00:00
public function options($option_type) {
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->where('option_type', $option_type);
return $this->db->get('user_options');
}
2023-08-18 13:30:04 +00:00
public function set_option($option_type, $option_name, $option_array) {
2023-08-18 12:49:12 +00:00
$uid=$this->session->userdata('user_id');
2023-08-18 13:30:04 +00:00
$sql='insert into user_options (user_id,option_type,option_name,option_key,option_value) values (?,?,?,?,?) ON DUPLICATE KEY UPDATE option_value=?';
2023-08-18 13:16:01 +00:00
foreach($option_array as $option_key => $option_value) {
2023-08-18 14:42:04 +00:00
$query = $this->db->query($sql, array($uid, $option_type, $option_name, $option_key, $option_value, $option_value));
}
}
public function get_options($option_type) {
$uid=$this->session->userdata('user_id');
$sql='select option_name,option_key,option_value from user_options where user_id=? and option_type=?';
return $this->db->query($sql, array($uid, $option_type));
2023-08-18 12:49:12 +00:00
}
}
?>