예제 #1
0
 public function getAllValues($Parameter)
 {
     try {
     } catch (PDOException $e) {
         MatchaErrorHandler::__errorProcess($e);
         return false;
     }
 }
예제 #2
0
파일: networkCCR.php 프로젝트: igez/gaiaehr
 /**
  * @return bool|mixed
  */
 public static function receiveCCR()
 {
     try {
         return file_get_contents('php://input');
     } catch (Exception $e) {
         MatchaErrorHandler::__errorProcess($e);
         return false;
     }
 }
예제 #3
0
 /**
  * function injectSQLThread($sqlStatement):
  * Method to send BIG SQL injections to the database
  * think of it throw and forget injection
  */
 public function run()
 {
     try {
         Matcha::$__conn->query($this->sqlStatement);
     } catch (PDOException $e) {
         MatchaErrorHandler::__errorProcess($e);
         return false;
     }
 }
예제 #4
0
 /**
  * function __destroySenchaMemoryModel($senchaModel = NULL):
  * Method to delete a sencha model stored in memory.
  * @param null $senchaModel
  * @param null $instance
  * @return bool
  */
 public static function __destroySenchaMemoryModel($senchaModel = null, $instance = null)
 {
     try {
         self::__checkMemoryModel();
         if (isset($instance)) {
             $senchaModel .= '_' . $instance;
         }
         self::$__conn->query("DELETE FROM _sencha_model WHERE model='{$senchaModel}';");
         return true;
     } catch (PDOException $e) {
         MatchaErrorHandler::__errorProcess($e);
         return false;
     }
 }
예제 #5
0
파일: Matcha.php 프로젝트: igez/gaiaehr
 /**
  * function __renderColumnSyntax($column = array()):
  * Method that will render the correct syntax for the addition or modification
  * of a column.
  */
 protected static function __renderColumnSyntax($column = array())
 {
     try {
         // parse some properties on Sencha model.
         // and do the defaults if properties are not set.
         if (isset($column['dataType'])) {
             $columnType = (string) strtoupper($column['dataType']);
         } elseif ($column['type'] == 'string') {
             $columnType = (string) 'VARCHAR';
         } elseif ($column['type'] == 'int') {
             $columnType = (string) 'INT';
             $column['len'] = isset($column['len']) ? $column['len'] : 11;
         } elseif ($column['type'] == 'bool' || $column['type'] == 'boolean') {
             $columnType = (string) 'TINYINT';
             $column['len'] = isset($column['len']) ? $column['len'] : 1;
         } elseif ($column['type'] == 'date') {
             $columnType = (string) 'DATETIME';
         } elseif ($column['type'] == 'float') {
             $columnType = (string) 'FLOAT';
         } elseif ($column['type'] == 'array') {
             $columnType = (string) 'MEDIUMTEXT';
         } else {
             return false;
         }
         // render the rest of the sql statement
         switch ($columnType) {
             case 'BIT':
             case 'TINYINT':
             case 'SMALLINT':
             case 'MEDIUMINT':
             case 'INT':
             case 'INTEGER':
             case 'BIGINT':
                 return $columnType . (isset($column['len']) ? $column['len'] ? '(' . $column['len'] . ') ' : '' : '') . (isset($column['defaultValue']) ? is_numeric($column['defaultValue']) && is_string((string) $column['defaultValue']) ? "DEFAULT '" . $column['defaultValue'] . "' " : '' : '') . (isset($column['comment']) ? $column['comment'] ? "COMMENT '" . $column['comment'] . "' " : '' : '') . (isset($column['allowNull']) ? $column['allowNull'] ? 'NOT NULL ' : '' : '') . (isset($column['autoIncrement']) ? $column['autoIncrement'] ? 'AUTO_INCREMENT ' : '' : '') . (isset($column['primaryKey']) ? $column['primaryKey'] ? 'PRIMARY KEY ' : '' : '');
                 break;
             case 'REAL':
             case 'DOUBLE':
             case 'FLOAT':
             case 'DECIMAL':
             case 'NUMERIC':
                 return $columnType . (isset($column['len']) ? $column['len'] ? '(' . $column['len'] . ')' : '(10,2)' : '(10,2)') . (isset($column['defaultValue']) ? is_numeric($column['defaultValue']) && is_string($column['defaultValue']) ? "DEFAULT '" . $column['defaultValue'] . "' " : '' : '') . (isset($column['comment']) ? $column['comment'] ? "COMMENT '" . $column['comment'] . "' " : '' : '') . (isset($column['allowNull']) ? $column['allowNull'] ? 'NOT NULL ' : '' : '') . (isset($column['autoIncrement']) ? $column['autoIncrement'] ? 'AUTO_INCREMENT ' : '' : '') . (isset($column['primaryKey']) ? $column['primaryKey'] ? 'PRIMARY KEY ' : '' : '');
                 break;
             case 'DATE':
             case 'TIME':
             case 'TIMESTAMP':
             case 'DATETIME':
             case 'YEAR':
                 return $columnType . ' ' . (isset($column['defaultValue']) ? is_numeric($column['defaultValue']) && is_string($column['defaultValue']) ? "DEFAULT '" . $column['defaultValue'] . "' " : '' : '') . (isset($column['comment']) ? $column['comment'] ? "COMMENT '" . $column['comment'] . "' " : '' : '') . (isset($column['allowNull']) ? $column['allowNull'] ? 'NOT NULL ' : '' : '');
                 break;
             case 'CHAR':
             case 'VARCHAR':
                 return $columnType . ' ' . (isset($column['len']) ? $column['len'] ? '(' . $column['len'] . ') ' : '(255)' : '(255)') . (isset($column['defaultValue']) ? is_numeric($column['defaultValue']) && is_string($column['defaultValue']) ? "DEFAULT '" . $column['defaultValue'] . "' " : '' : '') . (isset($column['comment']) ? $column['comment'] ? "COMMENT '" . $column['comment'] . "' " : '' : '') . (isset($column['allowNull']) ? $column['allowNull'] ? 'NOT NULL ' : '' : '');
                 break;
             case 'BINARY':
             case 'VARBINARY':
                 return $columnType . ' ' . (isset($column['len']) ? $column['len'] ? '(' . $column['len'] . ') ' : '(1000)' : '(1000)') . (isset($column['allowNull']) ? $column['allowNull'] ? '' : 'NOT NULL ' : '') . (isset($column['comment']) ? $column['comment'] ? "COMMENT '" . $column['comment'] . "'" : '' : '');
                 break;
             case 'TINYBLOB':
             case 'BLOB':
             case 'MEDIUMBLOB':
             case 'LONGBLOB':
             case 'TINYTEXT':
             case 'TEXT':
             case 'MEDIUMTEXT':
             case 'LONGTEXT':
                 return $columnType . ' ' . (isset($column['allowNull']) ? $column['allowNull'] ? 'NOT NULL ' : '' : '') . (isset($column['comment']) ? $column['comment'] ? "COMMENT '" . $column['comment'] . "'" : '' : '');
                 break;
             default:
                 throw new Exception('No data type is defined.');
                 break;
         }
     } catch (Exception $e) {
         MatchaErrorHandler::__errorProcess($e);
         return false;
     }
 }
예제 #6
0
 /**
  * function __diffTriggers($senchaModel):
  * Method to make changes on the trigger, if the trigger is different
  * @param $senchaModel
  * @return bool
  */
 private static function __diffTriggers($senchaModel)
 {
     try {
         if (empty($senchaModel['triggers'])) {
             return false;
         }
         $databaseTriggers = self::$__conn->query("SHOW TRIGGERS LIKE '" . $senchaModel['table']['name'] . "';");
         // get all the triggers names of each model (Sencha and Database-table)
         $tableTrigger = array();
         $senchaTrigger = array();
         foreach ($databaseTriggers as $trigger) {
             $tableTrigger[] = $trigger['Trigger'];
         }
         foreach ($senchaModel['triggers'] as $trigger) {
             $senchaTrigger[] = $trigger['name'];
         }
         // get all the triggers that are not present in the database-table and sencha model
         $differentCreateTrigger = array_diff($senchaTrigger, $tableTrigger);
         $differentDropTrigger = array_diff($tableTrigger, $senchaTrigger);
         if (count($tableTrigger) <= 1) {
             self::__createAllTriggers($senchaModel, $senchaModel['table']['name']);
             return true;
         } elseif (count($differentCreateTrigger) || count($differentDropTrigger)) {
             foreach ($differentCreateTrigger as $trigger) {
                 self::__createTrigger($senchaModel['table']['name'], $trigger);
             }
             foreach ($differentDropTrigger as $trigger) {
                 self::__destroyTrigger($senchaModel['table']['name'], $trigger['Trigger']);
             }
         } else {
             foreach ($senchaModel['triggers'] as $senchaTrigger) {
                 $change = false;
                 foreach ($databaseTriggers as $databaseTrigger) {
                     if (strtolower($databaseTrigger['Trigger']) == strtolower($senchaTrigger['name'])) {
                         if (strtolower($databaseTrigger['Event']) != strtolower($senchaTrigger['event'])) {
                             $change = true;
                         }
                         if (strtolower($databaseTrigger['Timing']) != strtolower($senchaTrigger['time'])) {
                             $change = true;
                         }
                         if (strtolower($databaseTrigger['Statement']) != strtolower($senchaTrigger['definition'])) {
                             $change = true;
                         }
                         if ($change) {
                             self::__destroyTrigger($senchaModel['table']['name'], $databaseTrigger['Trigger']);
                             self::__createTrigger($senchaModel['table']['name'], $senchaTrigger);
                         }
                     }
                 }
             }
         }
         return true;
     } catch (PDOException $e) {
         MatchaErrorHandler::__errorProcess($e);
         return false;
     }
 }
예제 #7
0
 /**
  * function __errorLogFile:
  * A file that MatchaErrorHandler will put all the errors 
  * events generated by Matcha::connect
  */
 public static function __errorLogFile($file = NULL)
 {
     self::$__logFile = $file;
 }
예제 #8
0
 /**
  * function defineLogModel($logModelArray):
  * Method to define the audit log structure all data and definition will be saved in LOG table.
  * @param $logModelArray
  * @return bool or exception
  */
 public static function defineLogModel($logModelArray)
 {
     try {
         if (!is_object(self::$__conn)) {
             return false;
         }
         //check if the table exist
         $recordSet = self::$__conn->query("SHOW TABLES LIKE '" . self::$hookTable . "';");
         if (isset($recordSet)) {
             self::__createTable(self::$hookTable);
         }
         unset($recordSet);
         // get the table column information and remove the id column
         // from the log table
         $tableColumns = self::$__conn->query("SHOW FULL COLUMNS IN " . self::$hookTable . ";")->fetchAll();
         unset($tableColumns[MatchaUtils::__recursiveArraySearch('id', $tableColumns)]);
         // prepare the columns from the table and passed array for comparison
         $columnsTableNames = array();
         $columnsLogModelNames = array();
         foreach ($tableColumns as $column) {
             $columnsTableNames[] = $column['Field'];
         }
         foreach ($logModelArray as $column) {
             $columnsLogModelNames[] = $column['name'];
         }
         // get all the column that are not present in the database-table
         $differentCreateColumns = array_diff($columnsLogModelNames, $columnsTableNames);
         $differentDropColumns = array_diff($columnsTableNames, $columnsLogModelNames);
         if (count($differentCreateColumns) || count($differentDropColumns)) {
             // create columns on the database
             foreach ($differentCreateColumns as $key => $column) {
                 self::__createColumn($logModelArray[$key], self::$hookTable);
             }
             // remove columns from the table
             foreach ($differentDropColumns as $column) {
                 self::__dropColumn($column, self::$hookTable);
             }
         }
         return true;
     } catch (PDOException $e) {
         MatchaErrorHandler::__errorProcess($e);
         return false;
     }
 }
예제 #9
0
 /**
  * function destroy($record): (part of CRUD) delete
  * will delete the record indicated by an id
  *
  * @param      $record
  * @param null $filter
  *
  * @return mixed
  */
 public function destroy($record, $filter = null)
 {
     try {
         if (is_object($record)) {
             $this->destroyRecord($record, $filter);
         } else {
             foreach ($record as $rec) {
                 $this->destroyRecord($rec, $filter);
             }
         }
         return ['success' => $this->rowsAffected > 0];
     } catch (PDOException $e) {
         return MatchaErrorHandler::__errorProcess($e);
     }
 }
예제 #10
0
 /**
  * function __destroySenchaMemoryModel($senchaModel = NULL):
  * Method to delete a sencha model stored in memory.
  * @param null $senchaModel
  * @return bool
  */
 public static function __destroySenchaMemoryModel($senchaModel = NULL)
 {
     try {
         self::__checkMemoryModel();
         self::$__conn->query("DELETE FROM _sencha_model WHERE model='{$senchaModel}';");
         return true;
     } catch (PDOException $e) {
         MatchaErrorHandler::__errorProcess($e);
         return false;
     }
 }