36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* trait berfungsi untuk log insert update dan delete
|
|
*/
|
|
namespace Aiko;
|
|
use PDO;
|
|
use PDOException;
|
|
use ErrorException;
|
|
trait Logdb
|
|
{
|
|
/**
|
|
* summary
|
|
*/
|
|
public function insertLog($tableName,$data,$transactionType,$actionBy)
|
|
{
|
|
try {
|
|
// print_r($tableName);
|
|
// print_r($data);
|
|
// print_r($transactionType);
|
|
// print_r($actionBy);
|
|
$sql = 'insert into log_transaction(`table_name`,`data`,`transaction_type`,`action_by`)values(
|
|
:table_name,:data,:transaction_type,:action_by)';
|
|
$stmt = $this->registry->db->prepare($sql);
|
|
$stmt->bindValue(':table_name',$tableName, PDO::PARAM_STR);
|
|
$stmt->bindValue(':data',$data,PDO::PARAM_STR);
|
|
$stmt->bindValue(':transaction_type',$transactionType,PDO::PARAM_STR);
|
|
$stmt->bindValue(':action_by',$actionBy,PDO::PARAM_STR);
|
|
$stmt->execute();
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
return false;
|
|
} catch (ErrorException $e) {
|
|
return false;
|
|
}
|
|
}
|
|
} |