/
Saved_control.php
79 lines (66 loc) · 1.45 KB
/
Saved_control.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php if ( ! defined('BASEPATH')) die('No direct script access allowed');
class Saved_control extends CActiveRecord {
/**
* Returns the table's name
*
* @access public
* @return string
*/
public function tableName()
{
return '{{saved_control}}';
}
/**
* Returns the table's primary key
*
* @access public
* @return string
*/
public function primaryKey()
{
return 'sid';
}
/**
* Return the static model for this table
*
* @static
* @access public
* @return CActiveRecord
*/
public static function model()
{
return parent::model(__CLASS__);
}
function getAllRecords($condition=FALSE)
{
if ($condition != FALSE)
{
$this->db->where($condition);
}
$data = $this->db->get('saved_control');
return $data;
}
function getSomeRecords($fields,$condition=FALSE)
{
foreach ($fields as $field)
{
$this->db->select($field);
}
if ($condition != FALSE)
{
$this->db->where($condition);
}
$data = $this->db->get('saved_control');
return $data;
}
public function getCountOfAll($sid)
{
$data = Yii::app()->db->createCommand("SELECT COUNT(*) AS countall FROM {{saved_control}} WHERE sid=$sid")->query();
$row = $data->read();
return $row['countall'];
}
function insertRecords($data)
{
return $this->db->insert('saved_control', $data);
}
}