mirror of
https://github.com/optim-enterprises-bv/control-pane.git
synced 2025-11-02 02:48:02 +00:00
* fixed tasklog select
This commit is contained in:
14
php/db.php
14
php/db.php
@@ -15,7 +15,6 @@ class Db {
|
|||||||
|
|
||||||
if (is_null($connect)){
|
if (is_null($connect)){
|
||||||
list($file_name, $connect) = $this->prep_connect($place, $database);
|
list($file_name, $connect) = $this->prep_connect($place, $database);
|
||||||
|
|
||||||
if(is_null($file_name) || !file_exists($file_name)){
|
if(is_null($file_name) || !file_exists($file_name)){
|
||||||
$this->error=true;
|
$this->error=true;
|
||||||
$this->error_message='DB file name not set or not found!';
|
$this->error_message='DB file name not set or not found!';
|
||||||
@@ -38,7 +37,6 @@ class Db {
|
|||||||
$this->error=true;
|
$this->error=true;
|
||||||
$this->error_message=$e->getMessage(); //'DB Error';
|
$this->error_message=$e->getMessage(); //'DB Error';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function prep_connect($place, $database){
|
private function prep_connect($place, $database){
|
||||||
@@ -131,6 +129,9 @@ class Db {
|
|||||||
|
|
||||||
# TODO once tested $values can have a default value of an empty array
|
# TODO once tested $values can have a default value of an empty array
|
||||||
function select($sql, $values, $single = false){
|
function select($sql, $values, $single = false){
|
||||||
|
if ($this->error){
|
||||||
|
return array('error' => $this->error, 'info' => $this->error_message);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
$query = $this->_pdo->prepare($sql);
|
$query = $this->_pdo->prepare($sql);
|
||||||
$i = 1;
|
$i = 1;
|
||||||
@@ -150,8 +151,7 @@ class Db {
|
|||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
} catch(PDOException $e) {
|
} catch(PDOException $e) {
|
||||||
# TODO: Handling ?
|
return array('error' => $this->error, 'info' => $this->error_message);
|
||||||
return array();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +160,9 @@ class Db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function insert($sql, $values){
|
function insert($sql, $values){
|
||||||
|
if ($this->error){
|
||||||
|
return array('error' => $this->error, 'info' => $this->error_message);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
$this->_pdo->beginTransaction();
|
$this->_pdo->beginTransaction();
|
||||||
$query = $this->_pdo->prepare($sql);
|
$query = $this->_pdo->prepare($sql);
|
||||||
@@ -184,6 +187,9 @@ class Db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update($sql, $values){
|
function update($sql, $values){
|
||||||
|
if ($this->error){
|
||||||
|
throw new Exception($this->error_message);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
$this->_pdo->beginTransaction();
|
$this->_pdo->beginTransaction();
|
||||||
$query = $this->_pdo->prepare($sql);
|
$query = $this->_pdo->prepare($sql);
|
||||||
|
|||||||
@@ -3,11 +3,8 @@
|
|||||||
$username=$this->_user_info['username'];
|
$username=$this->_user_info['username'];
|
||||||
|
|
||||||
$db=new Db('base','cbsdtaskd');
|
$db=new Db('base','cbsdtaskd');
|
||||||
Utils::clonos_syslog("tasklog: ". "SELECT id,st_time,end_time,cmd,status,errcode,logfile FROM taskd WHERE owner='". $username."' ORDER BY id DESC;");
|
|
||||||
//olevole why array?!
|
|
||||||
//$res=$db->select("SELECT id,st_time,end_time,cmd,status,errcode,logfile FROM taskd WHERE owner='?' ORDER BY id DESC", array([$username]));
|
|
||||||
|
|
||||||
$res=$db->select("SELECT id,st_time,end_time,cmd,status,errcode,logfile FROM taskd WHERE owner='".$username."' ORDER BY id DESC", $username);
|
$res=$db->select("SELECT id,st_time,end_time,cmd,status,errcode,logfile FROM taskd WHERE owner=? ORDER BY id DESC", array([$username]));
|
||||||
|
|
||||||
$html='';
|
$html='';
|
||||||
if($res!==false)
|
if($res!==false)
|
||||||
@@ -17,7 +14,7 @@ if($res!==false)
|
|||||||
|
|
||||||
if(!empty($res)) foreach($res as $item)
|
if(!empty($res)) foreach($res as $item)
|
||||||
{
|
{
|
||||||
Utils::clonos_syslog("tasklog: HTML");
|
//Utils::clonos_syslog("tasklog: HTML");
|
||||||
|
|
||||||
$hres=$this->getTableChunk('tasklog','tbody');
|
$hres=$this->getTableChunk('tasklog','tbody');
|
||||||
if($hres!==false)
|
if($hres!==false)
|
||||||
|
|||||||
Reference in New Issue
Block a user