<?php
class soft_model extends SDF_Model
{
var $title = '';
var $content = '';
var $date = '';
public $soft_id; public function __construct(){
$this->db = $this->load->database('default',true);
parent::__construct();
$this->load->helper('cookie');
$this->soft_id = $this->input->cookie('soft_id');
}
public function get_soft_list(){
$soft_arr = $this->db->select('soft_id,name')->get_where('soft')->result_array();
$list = array();
foreach($soft_arr as $user){
$list[$user['soft_id']] = $user;
}
return $list;
}
public function get_soft_names(){
$soft_arr = $this->db->select('soft_id,name')->get_where('soft')->result_array();
$soft_names = array();
foreach($soft_arr as $user){
$soft_names[$user['soft_id']] = $user['soft_id'].'| '.$user['name'];
}
return $soft_names;
}
public function get_version_names(){
$soft_arr = $this->db->select('id,soft_id,version')->get_where('soft_version')->result_array();
$soft_names = array();
foreach($soft_arr as $user){
$soft_names[$user['id']] =$user['version'];
}
return $soft_names;
}
public function get_region_nick(){
$region = array();
$region[0]='其它';
$region_arr = $this->db->select('region_id,region_name')->get_where('region')->result_array();
foreach ($region_arr as $v){
$region[$v['region_id']] = $v['region_name'];
}
return $region;
}
public function get_channel_account(){
$channel_account = array();
$channel_account_arr = $this->db->select('id,username,nick,principald_id,media,cooperation')->get_where('channel_account',array('soft_id'=>$this->soft_id))->result_array();
foreach ($channel_account_arr as $k=>$v){
$channel_account[$v['id']] = $v;
}
unset($channel_account_arr);
return $channel_account;
}
public function get_channel_names(){
$channel_arr = $this->db->select('id,username,nick,principald_id,media,cooperation')->get_where('channel_account',array())->result_array();
return $channel_arr;
}
public function get_region_names(){
$region[0]=array('region_id'=>0,'region_name'=>'其它');
$region_arr = $this->db->select('region_id,region_name')->get_where('region',array('region_type'=>1))->result_array();
foreach ($region_arr as $k=>$v){
$region[$v['region_id']] = $v;
}
unset($region_arr);
return $region;
}
public function Get_Entitys($entity_type_id=''){
$entity = array();
$this->db->dbprefix = 'eav_';
if($entity_type_id){
$entity_arr = $this->db->select('entity_id,title')->order_by('entity_id')->get_where('entity',array('entity_type_id'=>$entity_type_id,'soft_id'=>get_cookie('soft_id')))->result_array();}else{
$entity_arr = $this->db->select('entity_id,title')->order_by('entity_id')->get_where('entity',array('soft_id'=>get_cookie('soft_id')))->result_array();}
foreach ($entity_arr as $v){
$entity[$v['entity_id']] = $v;
}
unset($entity_arr);
return $entity;
}
function get_soft_info($softid)
{
$this->db->where(array('soft_id'=> $softid));
$this->db->from('soft');
$query = $this->db->get();
$list = $query->result_array();
return $list[0];
}
public function get_softs_names(){
$arr = $this->db->select('soft_id,name')->get_where('soft',array())->result_array();
foreach ($arr as $v){
$soft_arr[$v['soft_id']] = $v;
}
unset($arr);
return $soft_arr;
}
public function get_version_list($where = array()){
$arr = $this->db->select('*')->get_where('soft_version',$where)->result_array();
return $arr;
}
public function Get_motion($soft_id=0){
$motion_arr = $this->db->select('id,m_name,parent_id')->order_by('id')->get_where('motion',array('soft_id'=>$soft_id))->result_array();
$m_arr = array();
foreach($motion_arr as $row){
$m_arr[$row['parent_id']][] = $row;
}
return $m_arr;
}
public function Get_motion_name($motion_id){
$motion_name = $this->db->select('id,m_name')->order_by('id')->get_where('motion',array('id'=>$motion_id))->row_array();
return $motion_name;
}
public function Get_software($soft_id){
$software = $this->db->select('id,software_name,course_flag,icon,keywords')->order_by('id')->get_where('software',array('soft_id' => $soft_id))->result_array();
return $software;
}
public function get_auxiliary_names($motion_id){
$v_name = $this->db->select('id,motion_flag,v1,v2,v3')->get_where('motion',array('id'=>$motion_id))->result_array();
return $v_name;
}
public function get_auxiliary_dictionary(){
$list = $this->db->select('id,motion_flag,flag_name,flag_v')->get_where('dictionary',array('soft_id'=>get_cookie('soft_id')))->result_array();
$v_arr = array();
foreach($list as $row){
$v_arr[$row['flag_v']][$row['motion_flag']] = $row['flag_name'];
}
return $v_arr;
}
}