This commit is contained in:
kaetemi 2014-09-03 04:46:08 +02:00
parent 978c09b029
commit 04ef076448
6 changed files with 249 additions and 253 deletions

View file

@ -115,7 +115,7 @@ class Assigned{
*/ */
public function create() { public function create() {
$dbl = new DBLayer("lib"); $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() { public function delete() {
$dbl = new DBLayer("lib"); $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"));
} }
/** /**

View file

@ -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. * @param array $data array of data to insert in format('fieldname' => $value,....). 'fieldname' must be a field in that table.
* @throws error in inserting. * @throws error in inserting.
*/ */
public function insert( $tb_name, $data ) { public function insert($tb_name, $data, $datafunc = array()) {
$this->useDb(); $this->useDb();
$field_values = ':' . implode( ',:', array_keys( $data ) ); $field_options = implode(',', array_merge(array_keys($data), array_keys($datafunc)));
$field_options = implode( ',', array_keys( $data ) ); $field_values = implode(',', array_merge(array(':' . implode(',:', array_keys($data))), array_values($datafunc)));
try { try {
$sth = $this -> PDO -> prepare( "INSERT INTO $tb_name ($field_options) VALUE ($field_values)" ); $sth = $this->PDO->prepare("INSERT INTO $tb_name ($field_options) VALUE ($field_values)");
foreach ( $data as $key => $value ) foreach ($data as $key => $value) {
{ $sth->bindValue(":$key", $value);
$sth -> bindValue( ":$key", $value );
} }
$this -> PDO -> beginTransaction(); $this->PDO->beginTransaction();
// execution // execution
$sth -> execute(); $sth->execute();
$this -> PDO -> commit(); $this->PDO->commit();
} }
catch ( Exception $e ) catch (Exception $e) {
{
// for rolling back the changes during transaction // for rolling back the changes during transaction
$this -> PDO -> rollBack(); $this->PDO->rollBack();
throw new Exception( "error in inserting" ); throw $e; // new Exception("error in inserting");
} }
} }

View file

@ -100,7 +100,7 @@ class Forwarded{
*/ */
public function delete() { public function delete() {
$dbl = new DBLayer("lib"); $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"));
} }

View file

@ -343,7 +343,7 @@ class Ticket{
*/ */
public function create(){ public function create(){
$dbl = new DBLayer("lib"); $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()'));
} }

View file

@ -82,8 +82,8 @@ class Ticket_Log{
global $TICKET_LOGGING; global $TICKET_LOGGING;
if($TICKET_LOGGING){ if($TICKET_LOGGING){
$dbl = new DBLayer("lib"); $dbl = new DBLayer("lib");
$values = Array('Timestamp'=>now(), 'Query' => json_encode(array($action,$arg)), 'Ticket' => $ticket_id, 'Author' => $author_id); $values = Array('Query' => json_encode(array($action,$arg)), 'Ticket' => $ticket_id, 'Author' => $author_id);
$dbl->insert("ticket_log", $values); $dbl->insert("ticket_log", $values, array('Timestamp'=>'now()'));
} }
} }

View file

@ -123,7 +123,7 @@ class Ticket_Reply{
*/ */
public function create(){ public function create(){
$dbl = new DBLayer("lib"); $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()'));
} }
/** /**