mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 01:09:50 +00:00
Fix #180
This commit is contained in:
parent
011869167d
commit
fdc514b039
6 changed files with 249 additions and 253 deletions
|
@ -115,7 +115,7 @@ class Assigned{
|
|||
*/
|
||||
public function create() {
|
||||
$dbl = new DBLayer("lib");
|
||||
$dbl->insert("`assigned`", Array('User' => $this->getUser(), 'Ticket' => $this->getTicket());
|
||||
$dbl->insert("`assigned`", Array('User' => $this->getUser(), 'Ticket' => $this->getTicket()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,7 +125,7 @@ class Assigned{
|
|||
*/
|
||||
public function delete() {
|
||||
$dbl = new DBLayer("lib");
|
||||
$dbl->delete("`assigned`", array('user_id' => $this->getUser() ,'ticket_id' => $this->getTicket(), "`User` = :user_id and `Ticket` = :ticket_id");
|
||||
$dbl->delete("`assigned`", array('user_id' => $this->getUser() ,'ticket_id' => $this->getTicket(), "`User` = :user_id and `Ticket` = :ticket_id"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -240,28 +240,24 @@ class DBLayer {
|
|||
* @param array $data array of data to insert in format('fieldname' => $value,....). 'fieldname' must be a field in that table.
|
||||
* @throws error in inserting.
|
||||
*/
|
||||
public function insert( $tb_name, $data ) {
|
||||
public function insert($tb_name, $data, $datafunc = array()) {
|
||||
$this->useDb();
|
||||
$field_values = ':' . implode( ',:', array_keys( $data ) );
|
||||
$field_options = implode( ',', array_keys( $data ) );
|
||||
$field_options = implode(',', array_merge(array_keys($data), array_keys($datafunc)));
|
||||
$field_values = implode(',', array_merge(array(':' . implode(',:', array_keys($data))), array_values($datafunc)));
|
||||
try {
|
||||
$sth = $this -> PDO -> prepare( "INSERT INTO $tb_name ($field_options) VALUE ($field_values)" );
|
||||
foreach ( $data as $key => $value )
|
||||
{
|
||||
|
||||
$sth -> bindValue( ":$key", $value );
|
||||
$sth = $this->PDO->prepare("INSERT INTO $tb_name ($field_options) VALUE ($field_values)");
|
||||
foreach ($data as $key => $value) {
|
||||
$sth->bindValue(":$key", $value);
|
||||
}
|
||||
$this -> PDO -> beginTransaction();
|
||||
$this->PDO->beginTransaction();
|
||||
// execution
|
||||
$sth -> execute();
|
||||
$this -> PDO -> commit();
|
||||
|
||||
$sth->execute();
|
||||
$this->PDO->commit();
|
||||
}
|
||||
catch ( Exception $e )
|
||||
{
|
||||
catch (Exception $e) {
|
||||
// for rolling back the changes during transaction
|
||||
$this -> PDO -> rollBack();
|
||||
throw new Exception( "error in inserting" );
|
||||
$this->PDO->rollBack();
|
||||
throw $e; // new Exception("error in inserting");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ class Forwarded{
|
|||
*/
|
||||
public function delete() {
|
||||
$dbl = new DBLayer("lib");
|
||||
$dbl->delete("`forwarded`", array('group_id' => $this->getGroup() ,'ticket_id' => $this->getTicket(), "`Group` = :group_id and `Ticket` = :ticket_id");
|
||||
$dbl->delete("`forwarded`", array('group_id' => $this->getGroup() ,'ticket_id' => $this->getTicket(), "`Group` = :group_id and `Ticket` = :ticket_id"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ class Ticket{
|
|||
*/
|
||||
public function create(){
|
||||
$dbl = new DBLayer("lib");
|
||||
$this->tId = $dbl->executeReturnId("ticket", Array('Timestamp'=>now(), 'Title' => $this->title, 'Status' => $this->status, 'Queue' => $this->queue, 'Ticket_Category' => $this->ticket_category, 'Author' => $this->author, 'Priority' => $this->priority));
|
||||
$this->tId = $dbl->executeReturnId("ticket", Array('Title' => $this->title, 'Status' => $this->status, 'Queue' => $this->queue, 'Ticket_Category' => $this->ticket_category, 'Author' => $this->author, 'Priority' => $this->priority), array('Timestamp'=>'now()'));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -82,8 +82,8 @@ class Ticket_Log{
|
|||
global $TICKET_LOGGING;
|
||||
if($TICKET_LOGGING){
|
||||
$dbl = new DBLayer("lib");
|
||||
$values = Array('Timestamp'=>now(), 'Query' => json_encode(array($action,$arg)), 'Ticket' => $ticket_id, 'Author' => $author_id);
|
||||
$dbl->insert("ticket_log", $values);
|
||||
$values = Array('Query' => json_encode(array($action,$arg)), 'Ticket' => $ticket_id, 'Author' => $author_id);
|
||||
$dbl->insert("ticket_log", $values, array('Timestamp'=>'now()'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ class Ticket_Reply{
|
|||
*/
|
||||
public function create(){
|
||||
$dbl = new DBLayer("lib");
|
||||
$this->tReplyId = $dbl->executeReturnId("ticket_reply", Array('Ticket' => $this->ticket, 'Content' => $this->content, 'Author' => $this->author,'Timestamp'=>now(), 'Hidden' => $this->hidden));
|
||||
$this->tReplyId = $dbl->executeReturnId("ticket_reply", Array('Ticket' => $this->ticket, 'Content' => $this->content, 'Author' => $this->author, 'Hidden' => $this->hidden), array('Timestamp'=>'now()'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue