Hệ thống quản lý trường học bằng PHP / MySQLi

1 <?php
2 /*
3  Reportico - PHP Reporting Tool
4  Copyright (C)
2010-2014 Peter Deed
5
6  This program
is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  
as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10  
11  This program
is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License
for more details.
15
16  You should have received a copy of the GNU General Public License
17  along with
this program; if not, write to the Free Software
18  Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20  * File: swmodify.php
21  *
22  * Base
class for handling generic updating functionality
23  * to the database
where details of an operation, a data view name
24  * a key and values are passed within the URL
25  *
26  * @link http://www.reportico.org/
27  * @copyright
2010-2014 Peter Deed
28  * @author Peter Deed <info@reportico.org>
29  * @package Reportico
30  * @license - http://www.gnu.org/licenses/gpl-
2.0.html GNU/GPL
31  * @version $Id: swmodify.php,v
1.8 2014/05/17 15:12:31 peter Exp $
32  */

33
34 class
reportico_db_engine
35 {
36     
public $pdo;
37     
public $stmt;
38     
public $last_sql;
39     
public $errorno;
40     
public $errormsg;
41     
public $errortext;
42
43     function __construct($in_pdo)
44     {
45         $
this->pdo = $in_pdo;
46     }
47     
48     function executeSQL( $in_sql, $no_rows_is_error =
false )
49     {
50             $
this->last_sql = $in_sql;
51             $
this->stmt = $this->pdo->query($in_sql);
52             
if ( !$this->stmt )
53             {
54                    $
this->storeErrorMessage();
55                    
return ( $this->stmt);
56             }
57
58             
if ( $no_rows_is_error )
59             {
60                 
if ( $this->getRowsAffected() == 0 )
61                 {
62                     $
this->errorno = "100";
63                     $
this->errormsg = "Warning - No data was affected by the operation";
64                     $
this->last_sql = "";
65                     
return false;
66                 }
67                 
68             }
69             
return $this->stmt;
70     }
71     
72     function fetch()
73     {
74             $result = $
this->stmt->fetch();
75             
return $result;
76     }
77     
78     function close()
79     {
80             $
this->stmt = null;
81     }
82     
83     function storeErrorMessage()
84     {
85             $arr = $
this->pdo->errorInfo();
86             $
this->errorno = $arr[0];
87             $
this->errormsg = $arr[2];
88     }
89
90     function getErrorMessage($add_sql =
true)
91     {
92         
return "Error ". $this->errorno. " - <BR>".$this->errormsg."<BR><BR>".$this->last_sql;
93     }
94
95     function showPDOError( )
96     {
97             $info = $
this->pdo->errorInfo();
98             $msg =
"Error ".$info[1]."<BR>".
99                     $info[
2];
100             trigger_error(
"$msg", E_USER_NOTICE);
101     }
102     
103     function getRowsAffected( )
104     {
105             
return $this->stmt->rowCount();
106     }
107     
108     function rpt_setDirtyRead()
109     {
110         $sql =
"SET ISOLATION TO DIRTY READ";
111         
return $this->pdo->Execute($sql);
112     }
113     
114     
115     function perform_project_modifications ($project)
116     {
117         $filename = find_best_location_in_include_path(
"projects/".$project."/modification_rules.php");
118         $return_status = array (
119                     
"errstat" => 0,
120                     
"msgtext" => "Modification sucessful"
121                     );
122
123         
if ( is_file ( $filename ) )
124         {
125             require_once($filename);
126             custom_project_modifications(&$
this, $return_status);
127         }
128         
else
129         {
130             $return_status[
"errstat"] = -1;
131             $return_status[
"msgtext"] = "No modifcation rules were found";
132         }
133
134         
return $return_status;
135     }
136
137 }
138 ?>


Gõ tìm kiếm nhanh...