16 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
17 require_once SQ_CORE_PACKAGE_PATH.
'/system/triggers/trigger_action/trigger_action.inc';
54 public static function execute($settings, &$state)
56 if (empty($state[
'asset'])) {
58 if (empty($state[
'assetid'])) {
61 $state[
'asset'] = &$GLOBALS[
'SQ_SYSTEM']->am->getAsset($state[
'assetid']);
64 if (is_null($state[
'asset']))
return FALSE;
66 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
67 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
71 $bind_vars = Array(
'assetid' => (
string) $state[
'assetid']);
73 }
catch (Exception $e) {
74 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
75 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
76 throw new Exception(
'Unable to increment hit count due to database error: '.$e->getMessage());
80 if (!empty($asset_hit_count)) {
81 if (isset($asset_hit_count[0][
'hitcount'])) {
82 $new_hit_count = (int) $asset_hit_count[0][
'hitcount'];
87 'assetid' => (
string) $state[
'assetid'],
88 'hitcount' => $new_hit_count,
91 }
catch (Exception $e) {
92 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
93 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
94 throw new Exception(
'Unable to increment hit count due to database error: '.$e->getMessage());
103 'assetid' => (
string) $state[
'assetid'],
107 }
catch (Exception $e) {
108 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
109 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
116 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
117 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
132 public static function getInterface($settings, $prefix, $write_access=FALSE)
168 public static function getLocks($settings, &$state)
170 return Array($state[
'assetid'] => Array(
'lookups'));