qcubed/framework

View on GitHub
includes/database/QPostgreSqlDatabase.class.php

Summary

Maintainability
F
1 wk
Test Coverage

Function SqlVariable has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

        public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false) {
            // Are we SqlVariabling a BOOLEAN value?
            if (is_bool($mixData)) {
                // Yes
                if ($blnIncludeEquality) {
Severity: Minor
Found in includes/database/QPostgreSqlDatabase.class.php - About 1 day to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File QPostgreSqlDatabase.class.php has 579 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
    /* QCubed Development Framework for PHP
     * http://www.qcu.be/
     *
     * Copyright (C) 2006
Severity: Major
Found in includes/database/QPostgreSqlDatabase.class.php - About 1 day to fix

    Method __construct has 130 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public function __construct($mixFieldData, $objDb = null) {
                $this->strName = $mixFieldData->GetColumn('column_name');
                $this->strOriginalName = $this->strName;
                $this->strTable = $mixFieldData->GetColumn('table_name');
                $this->strOriginalTable = $this->strTable;
    Severity: Major
    Found in includes/database/QPostgreSqlDatabase.class.php - About 5 hrs to fix

      Function __construct has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

              public function __construct($mixFieldData, $objDb = null) {
                  $this->strName = $mixFieldData->GetColumn('column_name');
                  $this->strOriginalName = $this->strName;
                  $this->strTable = $mixFieldData->GetColumn('table_name');
                  $this->strOriginalTable = $this->strTable;
      Severity: Minor
      Found in includes/database/QPostgreSqlDatabase.class.php - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      The class QPostgreSqlDatabase has an overall complexity of 70 which is very high. The configured complexity threshold is 50.
      Open

          class QPostgreSqlDatabase extends QDatabaseBase {
              /** Adapter name */
              const Adapter = 'PostgreSQL Database Adapter';
      
              protected $objPgSql;

      Method SqlVariable has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false) {
                  // Are we SqlVariabling a BOOLEAN value?
                  if (is_bool($mixData)) {
                      // Yes
                      if ($blnIncludeEquality) {
      Severity: Major
      Found in includes/database/QPostgreSqlDatabase.class.php - About 2 hrs to fix

        Method GetForeignKeysForTable has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public function GetForeignKeysForTable($strTableName) {
                    $objForeignKeyArray = array();
                    
                    // Use Query to pull the FKs
                    $strQuery = sprintf('
        Severity: Major
        Found in includes/database/QPostgreSqlDatabase.class.php - About 2 hrs to fix

          Method InsertOrUpdate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  public function InsertOrUpdate($strTable, $mixColumnsAndValuesArray, $strPKNames = null) {
                      $strEscapedArray = $this->EscapeIdentifiersAndValues($mixColumnsAndValuesArray);
                      $strColumns = array_keys($strEscapedArray);
                      $strUpdateStatement = '';
                      foreach ($strEscapedArray as $strColumn => $strValue) {
          Severity: Minor
          Found in includes/database/QPostgreSqlDatabase.class.php - About 1 hr to fix

            Function SqlLimitVariableSuffix has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function SqlLimitVariableSuffix($strLimitInfo) {
                        // Setup limit suffix (if applicable) via a LIMIT clause 
                        if (strlen($strLimitInfo)) {
                            if (strpos($strLimitInfo, ';') !== false)
                                throw new Exception('Invalid Semicolon in LIMIT Info');
            Severity: Minor
            Found in includes/database/QPostgreSqlDatabase.class.php - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function InsertOrUpdate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function InsertOrUpdate($strTable, $mixColumnsAndValuesArray, $strPKNames = null) {
                        $strEscapedArray = $this->EscapeIdentifiersAndValues($mixColumnsAndValuesArray);
                        $strColumns = array_keys($strEscapedArray);
                        $strUpdateStatement = '';
                        foreach ($strEscapedArray as $strColumn => $strValue) {
            Severity: Minor
            Found in includes/database/QPostgreSqlDatabase.class.php - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method GetIndexesForTable has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    public function GetIndexesForTable($strTableName) {
                        $objIndexArray = array();
                        
                        $objResult = $this->Query(sprintf('
                            SELECT 
            Severity: Minor
            Found in includes/database/QPostgreSqlDatabase.class.php - About 1 hr to fix

              Method GetFieldsForTable has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      public function GetFieldsForTable($strTableName) {
                          $strTableName = $this->SqlVariable($strTableName);
                          $strQuery = sprintf('
                              SELECT 
                                  columns.table_name,
              Severity: Minor
              Found in includes/database/QPostgreSqlDatabase.class.php - About 1 hr to fix

                Method GetColumn has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        public function GetColumn($strColumnName, $strColumnType = null) {
                            if (!isset($this->strColumnArray[$strColumnName])) {
                                return null;
                            }
                            $strColumnValue = $this->strColumnArray[$strColumnName];
                Severity: Minor
                Found in includes/database/QPostgreSqlDatabase.class.php - About 1 hr to fix

                  Avoid too many return statements within this method.
                  Open

                                  return $strToReturn . 'NULL';
                  Severity: Major
                  Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                        return  $strToReturn . sprintf("'%s'", $mixData->qFormat(QDateTime::FormatIso));
                    Severity: Major
                    Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return $strColumnValue;
                      Severity: Major
                      Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                                return $strToReturn . 'NULL'; // null date and time is a null value
                        Severity: Major
                        Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                              return QType::Cast($strColumnValue, QType::Integer);
                          Severity: Major
                          Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return  $strToReturn . sprintf("'%s'", $mixData->qFormat('hhhh:mm:ss'));
                            Severity: Major
                            Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return QType::Cast($strColumnValue, QType::Float);
                              Severity: Major
                              Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                            return "= '0'";
                                Severity: Major
                                Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                          return "'0'";
                                  Severity: Major
                                  Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                        return new QDateTime($strColumnValue);
                                    Severity: Major
                                    Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                              return 'NULL';
                                      Severity: Major
                                      Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                                    return "!= '0'";
                                        Severity: Major
                                        Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                          return $strToReturn . sprintf('%s', $mixData);
                                          Severity: Major
                                          Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                            return $strToReturn . $s;
                                            Severity: Major
                                            Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                          return $strToReturn . sprintf("'%s'", pg_escape_string($mixData));
                                              Severity: Major
                                              Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                        return "'1'";
                                                Severity: Major
                                                Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                                      return  $strToReturn . sprintf("'%s'", $mixData->qFormat('YYYY-MM-DD'));
                                                  Severity: Major
                                                  Found in includes/database/QPostgreSqlDatabase.class.php - About 30 mins to fix

                                                    The method SqlVariable() has an NPath complexity of 1500. The configured NPath complexity threshold is 200.
                                                    Open

                                                            public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false) {
                                                                // Are we SqlVariabling a BOOLEAN value?
                                                                if (is_bool($mixData)) {
                                                                    // Yes
                                                                    if ($blnIncludeEquality) {

                                                    NPathComplexity

                                                    Since: 0.1

                                                    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                    Example

                                                    class Foo {
                                                        function bar() {
                                                            // lots of complicated code
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                    The method __construct() has 170 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                    Open

                                                            public function __construct($mixFieldData, $objDb = null) {
                                                                $this->strName = $mixFieldData->GetColumn('column_name');
                                                                $this->strOriginalName = $this->strName;
                                                                $this->strTable = $mixFieldData->GetColumn('table_name');
                                                                $this->strOriginalTable = $this->strTable;

                                                    The method __construct() has an NPath complexity of 9600. The configured NPath complexity threshold is 200.
                                                    Open

                                                            public function __construct($mixFieldData, $objDb = null) {
                                                                $this->strName = $mixFieldData->GetColumn('column_name');
                                                                $this->strOriginalName = $this->strName;
                                                                $this->strTable = $mixFieldData->GetColumn('table_name');
                                                                $this->strOriginalTable = $this->strTable;

                                                    NPathComplexity

                                                    Since: 0.1

                                                    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                    Example

                                                    class Foo {
                                                        function bar() {
                                                            // lots of complicated code
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                    The method GetColumn() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
                                                    Open

                                                            public function GetColumn($strColumnName, $strColumnType = null) {
                                                                if (!isset($this->strColumnArray[$strColumnName])) {
                                                                    return null;
                                                                }
                                                                $strColumnValue = $this->strColumnArray[$strColumnName];

                                                    CyclomaticComplexity

                                                    Since: 0.1

                                                    Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                    Example

                                                    // Cyclomatic Complexity = 11
                                                    class Foo {
                                                    1   public function example() {
                                                    2       if ($a == $b) {
                                                    3           if ($a1 == $b1) {
                                                                    fiddle();
                                                    4           } elseif ($a2 == $b2) {
                                                                    fiddle();
                                                                } else {
                                                                    fiddle();
                                                                }
                                                    5       } elseif ($c == $d) {
                                                    6           while ($c == $d) {
                                                                    fiddle();
                                                                }
                                                    7        } elseif ($e == $f) {
                                                    8           for ($n = 0; $n < $h; $n++) {
                                                                    fiddle();
                                                                }
                                                            } else {
                                                                switch ($z) {
                                                    9               case 1:
                                                                        fiddle();
                                                                        break;
                                                    10              case 2:
                                                                        fiddle();
                                                                        break;
                                                    11              case 3:
                                                                        fiddle();
                                                                        break;
                                                                    default:
                                                                        fiddle();
                                                                        break;
                                                                }
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                    The method __construct() has a Cyclomatic Complexity of 37. The configured cyclomatic complexity threshold is 10.
                                                    Open

                                                            public function __construct($mixFieldData, $objDb = null) {
                                                                $this->strName = $mixFieldData->GetColumn('column_name');
                                                                $this->strOriginalName = $this->strName;
                                                                $this->strTable = $mixFieldData->GetColumn('table_name');
                                                                $this->strOriginalTable = $this->strTable;

                                                    CyclomaticComplexity

                                                    Since: 0.1

                                                    Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                    Example

                                                    // Cyclomatic Complexity = 11
                                                    class Foo {
                                                    1   public function example() {
                                                    2       if ($a == $b) {
                                                    3           if ($a1 == $b1) {
                                                                    fiddle();
                                                    4           } elseif ($a2 == $b2) {
                                                                    fiddle();
                                                                } else {
                                                                    fiddle();
                                                                }
                                                    5       } elseif ($c == $d) {
                                                    6           while ($c == $d) {
                                                                    fiddle();
                                                                }
                                                    7        } elseif ($e == $f) {
                                                    8           for ($n = 0; $n < $h; $n++) {
                                                                    fiddle();
                                                                }
                                                            } else {
                                                                switch ($z) {
                                                    9               case 1:
                                                                        fiddle();
                                                                        break;
                                                    10              case 2:
                                                                        fiddle();
                                                                        break;
                                                    11              case 3:
                                                                        fiddle();
                                                                        break;
                                                                    default:
                                                                        fiddle();
                                                                        break;
                                                                }
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                    The method SqlVariable() has a Cyclomatic Complexity of 21. The configured cyclomatic complexity threshold is 10.
                                                    Open

                                                            public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false) {
                                                                // Are we SqlVariabling a BOOLEAN value?
                                                                if (is_bool($mixData)) {
                                                                    // Yes
                                                                    if ($blnIncludeEquality) {

                                                    CyclomaticComplexity

                                                    Since: 0.1

                                                    Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                    Example

                                                    // Cyclomatic Complexity = 11
                                                    class Foo {
                                                    1   public function example() {
                                                    2       if ($a == $b) {
                                                    3           if ($a1 == $b1) {
                                                                    fiddle();
                                                    4           } elseif ($a2 == $b2) {
                                                                    fiddle();
                                                                } else {
                                                                    fiddle();
                                                                }
                                                    5       } elseif ($c == $d) {
                                                    6           while ($c == $d) {
                                                                    fiddle();
                                                                }
                                                    7        } elseif ($e == $f) {
                                                    8           for ($n = 0; $n < $h; $n++) {
                                                                    fiddle();
                                                                }
                                                            } else {
                                                                switch ($z) {
                                                    9               case 1:
                                                                        fiddle();
                                                                        break;
                                                    10              case 2:
                                                                        fiddle();
                                                                        break;
                                                    11              case 3:
                                                                        fiddle();
                                                                        break;
                                                                    default:
                                                                        fiddle();
                                                                        break;
                                                                }
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                    Avoid using undefined variables such as '$s' which will lead to PHP notices.
                                                    Open

                                                                    return $strToReturn . $s;

                                                    UndefinedVariable

                                                    Since: 2.8.0

                                                    Detects when a variable is used that has not been defined before.

                                                    Example

                                                    class Foo
                                                    {
                                                        private function bar()
                                                        {
                                                            // $message is undefined
                                                            echo $message;
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                                                    Missing class import via use statement (line '672', column '17').
                                                    Open

                                                                        return new QDateTime($strColumnValue);

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '895', column '16').
                                                    Open

                                                                        throw new QPostgreSqlDatabaseException('Unsupported Field Type: ' . $this->strType, 0, null);

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '133', column '16').
                                                    Open

                                                                        throw new Exception('Invalid Backtick in LIMIT Info');

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '354', column '15').
                                                    Open

                                                                    throw new Exception("Invalid Key Definition: $strKeyDefinition");

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '830', column '16').
                                                    Open

                                                                        throw new QPostgreSqlDatabaseException('Unsupported Field Type: money.  Use numeric or decimal instead.', 0,null);

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '848', column '17').
                                                    Open

                                                                            throw new QPostgreSqlDatabaseException('Unsupported Field Type: bit with MaxLength > 1', 0, null);

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '245', column '15').
                                                    Open

                                                                    throw new QPostgreSqlDatabaseException(pg_last_error(), 0, $strQuery);

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '482', column '26').
                                                    Open

                                                                    $objForeignKey = new QDatabaseForeignKey(

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '221', column '15').
                                                    Open

                                                                    throw new QPostgreSqlDatabaseException("Unable to connect to Database", -1, null);

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '304', column '32').
                                                    Open

                                                                    array_push($objFields, new QPostgreSqlDatabaseField($objRow, $this));

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '144', column '16').
                                                    Open

                                                                        throw new QPostgreSqlDatabaseException('Invalid Limit Info: ' . $strLimitInfo, 0, null);

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '359', column '15').
                                                    Open

                                                                    throw new Exception("Invalid Key Definition: $strKeyDefinition");

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    The method SqlVariable has a boolean flag argument $blnReverseEquality, which is a certain sign of a Single Responsibility Principle violation.
                                                    Open

                                                            public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false) {

                                                    BooleanArgumentFlag

                                                    Since: 1.4.0

                                                    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                                                    Example

                                                    class Foo {
                                                        public function bar($flag = true) {
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                                                    Missing class import via use statement (line '131', column '16').
                                                    Open

                                                                        throw new Exception('Invalid Semicolon in LIMIT Info');

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '157', column '16').
                                                    Open

                                                                        throw new Exception('Invalid Backtick in ORDER BY Info');

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    The method SqlVariable has a boolean flag argument $blnIncludeEquality, which is a certain sign of a Single Responsibility Principle violation.
                                                    Open

                                                            public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false) {

                                                    BooleanArgumentFlag

                                                    Since: 1.4.0

                                                    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                                                    Example

                                                    class Foo {
                                                        public function bar($flag = true) {
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                                                    Missing class import via use statement (line '155', column '16').
                                                    Open

                                                                        throw new Exception('Invalid Semicolon in ORDER BY Info');

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '257', column '15').
                                                    Open

                                                                    throw new QPostgreSqlDatabaseException(pg_last_error(), 0, $strNonQuery);

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '412', column '21').
                                                    Open

                                                                    $objIndex = new QDatabaseIndex($strKeyName, $blnPrimaryKey, $blnUnique, $strColumnNameArray);

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '249', column '34').
                                                    Open

                                                                $objPgSqlDatabaseResult = new QPostgreSqlDatabaseResult($objResult, $this);

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    Missing class import via use statement (line '606', column '16').
                                                    Open

                                                                    return new QPostgreSqlDatabaseRow($strColumnArray);

                                                    MissingImport

                                                    Since: 2.7.0

                                                    Importing all external classes in a file through use statements makes them clearly visible.

                                                    Example

                                                    function make() {
                                                        return new \stdClass();
                                                    }

                                                    Source http://phpmd.org/rules/cleancode.html#MissingImport

                                                    The method SqlVariable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                    Open

                                                                    } else {
                                                                        return  $strToReturn . sprintf("'%s'", $mixData->qFormat(QDateTime::FormatIso));
                                                                    }

                                                    ElseExpression

                                                    Since: 1.4.0

                                                    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                                                    Example

                                                    class Foo
                                                    {
                                                        public function bar($flag)
                                                        {
                                                            if ($flag) {
                                                                // one branch
                                                            } else {
                                                                // another branch
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/cleancode.html#elseexpression

                                                    The method SqlVariable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                    Open

                                                                    } else {
                                                                        // Check against NULL, True then False
                                                                        if (is_null($mixData))
                                                                            return 'NULL';
                                                                        else if ($mixData)

                                                    ElseExpression

                                                    Since: 1.4.0

                                                    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                                                    Example

                                                    class Foo
                                                    {
                                                        public function bar($flag)
                                                        {
                                                            if ($flag) {
                                                                // one branch
                                                            } else {
                                                                // another branch
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/cleancode.html#elseexpression

                                                    Avoid using static access to class 'QType' in method 'GetColumn'.
                                                    Open

                                                                        return QType::Cast($strColumnValue, QType::String);

                                                    StaticAccess

                                                    Since: 1.4.0

                                                    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                                                    Example

                                                    class Foo
                                                    {
                                                        public function bar()
                                                        {
                                                            Bar::baz();
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/cleancode.html#staticaccess

                                                    Avoid using static access to class 'QType' in method 'GetColumn'.
                                                    Open

                                                                        return QType::Cast($strColumnValue, QType::Integer);

                                                    StaticAccess

                                                    Since: 1.4.0

                                                    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                                                    Example

                                                    class Foo
                                                    {
                                                        public function bar()
                                                        {
                                                            Bar::baz();
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/cleancode.html#staticaccess

                                                    The method SqlVariable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                    Open

                                                                    } else {
                                                                        if (is_null($mixData))
                                                                            $strToReturn = 'IS ';
                                                                        else
                                                                            $strToReturn = '= ';

                                                    ElseExpression

                                                    Since: 1.4.0

                                                    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                                                    Example

                                                    class Foo
                                                    {
                                                        public function bar($flag)
                                                        {
                                                            if ($flag) {
                                                                // one branch
                                                            } else {
                                                                // another branch
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/cleancode.html#elseexpression

                                                    The method SqlVariable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                    Open

                                                                        } else {
                                                                            // Check against NULL, True then False
                                                                            if (is_null($mixData))
                                                                                return 'IS NULL';
                                                                            else if ($mixData)

                                                    ElseExpression

                                                    Since: 1.4.0

                                                    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                                                    Example

                                                    class Foo
                                                    {
                                                        public function bar($flag)
                                                        {
                                                            if ($flag) {
                                                                // one branch
                                                            } else {
                                                                // another branch
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/cleancode.html#elseexpression

                                                    The method InsertOrUpdate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                    Open

                                                                } else {
                                                                    $strPKNames = array($this->EscapeIdentifier($strPKNames));
                                                                }

                                                    ElseExpression

                                                    Since: 1.4.0

                                                    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                                                    Example

                                                    class Foo
                                                    {
                                                        public function bar($flag)
                                                        {
                                                            if ($flag) {
                                                                // one branch
                                                            } else {
                                                                // another branch
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/cleancode.html#elseexpression

                                                    The method GetColumn uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                    Open

                                                                        } else {
                                                                            return ($strColumnValue) ? true : false;
                                                                        }

                                                    ElseExpression

                                                    Since: 1.4.0

                                                    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                                                    Example

                                                    class Foo
                                                    {
                                                        public function bar($flag)
                                                        {
                                                            if ($flag) {
                                                                // one branch
                                                            } else {
                                                                // another branch
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/cleancode.html#elseexpression

                                                    The method SqlLimitVariableSuffix uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                    Open

                                                                    } else {
                                                                        throw new QPostgreSqlDatabaseException('Invalid Limit Info: ' . $strLimitInfo, 0, null);
                                                                    }

                                                    ElseExpression

                                                    Since: 1.4.0

                                                    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                                                    Example

                                                    class Foo
                                                    {
                                                        public function bar($flag)
                                                        {
                                                            if ($flag) {
                                                                // one branch
                                                            } else {
                                                                // another branch
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/cleancode.html#elseexpression

                                                    Avoid using static access to class 'QType' in method 'GetColumn'.
                                                    Open

                                                                        return QType::Cast($strColumnValue, QType::Float);

                                                    StaticAccess

                                                    Since: 1.4.0

                                                    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                                                    Example

                                                    class Foo
                                                    {
                                                        public function bar()
                                                        {
                                                            Bar::baz();
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/cleancode.html#staticaccess

                                                    Avoid unused local variables such as '$s'.
                                                    Open

                                                                    return $strToReturn . $s;

                                                    UnusedLocalVariable

                                                    Since: 0.2

                                                    Detects when a local variable is declared and/or assigned, but not used.

                                                    Example

                                                    class Foo {
                                                        public function doSomething()
                                                        {
                                                            $i = 5; // Unused
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

                                                    Avoid unused parameters such as '$strLimitInfo'.
                                                    Open

                                                            public function SqlLimitVariablePrefix($strLimitInfo) {

                                                    UnusedFormalParameter

                                                    Since: 0.2

                                                    Avoid passing parameters to methods or constructors and then not using those parameters.

                                                    Example

                                                    class Foo
                                                    {
                                                        private function bar($howdy)
                                                        {
                                                            // $howdy is not used
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                                                    Avoid using count() function in for loops.
                                                    Open

                                                                for ($intIndex = 0; $intIndex < count($strToReturn); $intIndex++) {
                                                                    $strColumn = $strToReturn[$intIndex];
                                                    
                                                                    if (substr($strColumn, 0, 1) == '"')
                                                                        $strColumn = substr($strColumn, 1, strpos($strColumn, '"', 1) - 1);

                                                    CountInLoopExpression

                                                    Since: 2.7.0

                                                    Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

                                                    Example

                                                    class Foo {
                                                    
                                                      public function bar()
                                                      {
                                                        $array = array();
                                                    
                                                        for ($i = 0; count($array); $i++) {
                                                          // ...
                                                        }
                                                      }
                                                    }

                                                    Source https://phpmd.org/rules/design.html#countinloopexpression

                                                    TODO found
                                                    Open

                                                                // TODO: Current method doesn't support key names with commas or parenthesis in them!

                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                    Open

                                                            public function GetForeignKeysForTable($strTableName) {
                                                                $objForeignKeyArray = array();
                                                                
                                                                // Use Query to pull the FKs
                                                                $strQuery = sprintf('
                                                    Severity: Major
                                                    Found in includes/database/QPostgreSqlDatabase.class.php and 1 other location - About 2 days to fix
                                                    includes/database/QPostgreSqlPdoDatabase.class.php on lines 324..397

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 435.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                    Open

                                                            public function InsertOrUpdate($strTable, $mixColumnsAndValuesArray, $strPKNames = null) {
                                                                $strEscapedArray = $this->EscapeIdentifiersAndValues($mixColumnsAndValuesArray);
                                                                $strColumns = array_keys($strEscapedArray);
                                                                $strUpdateStatement = '';
                                                                foreach ($strEscapedArray as $strColumn => $strValue) {
                                                    Severity: Major
                                                    Found in includes/database/QPostgreSqlDatabase.class.php and 1 other location - About 1 day to fix
                                                    includes/database/QPostgreSqlPdoDatabase.class.php on lines 13..50

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 356.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Identical blocks of code found in 3 locations. Consider refactoring.
                                                    Open

                                                            private function ParseColumnNameArrayFromKeyDefinition($strKeyDefinition) {
                                                                $strKeyDefinition = trim($strKeyDefinition);
                                                                
                                                                // Get rid of the opening "(" and the closing ")"
                                                                $intPosition = strpos($strKeyDefinition, '(');
                                                    Severity: Major
                                                    Found in includes/database/QPostgreSqlDatabase.class.php and 2 other locations - About 1 day to fix
                                                    includes/database/QInformixPdoDatabase.class.php on lines 325..355
                                                    includes/database/QPostgreSqlPdoDatabase.class.php on lines 253..283

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 307.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Similar blocks of code found in 4 locations. Consider refactoring.
                                                    Open

                                                            public function SqlLimitVariableSuffix($strLimitInfo) {
                                                                // Setup limit suffix (if applicable) via a LIMIT clause 
                                                                if (strlen($strLimitInfo)) {
                                                                    if (strpos($strLimitInfo, ';') !== false)
                                                                        throw new Exception('Invalid Semicolon in LIMIT Info');
                                                    Severity: Major
                                                    Found in includes/database/QPostgreSqlDatabase.class.php and 3 other locations - About 6 hrs to fix
                                                    includes/database/QInformixPdoDatabase.class.php on lines 195..218
                                                    includes/database/QPostgreSqlPdoDatabase.class.php on lines 164..186
                                                    includes/database/QSqLite3PdoDatabase.class.php on lines 128..149

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 209.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                    Open

                                                                if ($mixData instanceof QDateTime) {
                                                                    if ($mixData->IsTimeNull()) {
                                                                        if ($mixData->IsDateNull()) {
                                                                            return $strToReturn . 'NULL'; // null date and time is a null value
                                                                        }
                                                    Severity: Major
                                                    Found in includes/database/QPostgreSqlDatabase.class.php and 1 other location - About 2 hrs to fix
                                                    includes/database/QPostgreSqlPdoDatabase.class.php on lines 135..148

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 123.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Similar blocks of code found in 5 locations. Consider refactoring.
                                                    Open

                                                            public function GetFieldsForTable($strTableName) {
                                                                $strTableName = $this->SqlVariable($strTableName);
                                                                $strQuery = sprintf('
                                                                    SELECT 
                                                                        columns.table_name,
                                                    Severity: Major
                                                    Found in includes/database/QPostgreSqlDatabase.class.php and 4 other locations - About 45 mins to fix
                                                    includes/database/QInformixPdoDatabase.class.php on lines 269..309
                                                    includes/database/QPostgreSqlPdoDatabase.class.php on lines 210..240
                                                    includes/database/QSqlServer2005Database.class.php on lines 364..390
                                                    includes/database/QSqlServerDatabase.class.php on lines 311..336

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 96.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Similar blocks of code found in 8 locations. Consider refactoring.
                                                    Open

                                                            public function SqlSortByVariable($strSortByInfo) {
                                                                // Setup sorting information (if applicable) via a ORDER BY clause
                                                                if (strlen($strSortByInfo)) {
                                                                    if (strpos($strSortByInfo, ';') !== false)
                                                                        throw new Exception('Invalid Semicolon in ORDER BY Info');
                                                    Severity: Major
                                                    Found in includes/database/QPostgreSqlDatabase.class.php and 7 other locations - About 45 mins to fix
                                                    includes/database/QInformixPdoDatabase.class.php on lines 220..232
                                                    includes/database/QMySqliDatabase.class.php on lines 28..39
                                                    includes/database/QMySqliDatabase.class.php on lines 41..53
                                                    includes/database/QOracleDatabase.class.php on lines 60..72
                                                    includes/database/QPostgreSqlPdoDatabase.class.php on lines 188..200
                                                    includes/database/QSqlServer2005Database.class.php on lines 208..220
                                                    includes/database/QSqlServerDatabase.class.php on lines 153..165

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 96.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Avoid excessively long variable names like $mixColumnsAndValuesArray. Keep variable name length under 20.
                                                    Open

                                                            public function InsertOrUpdate($strTable, $mixColumnsAndValuesArray, $strPKNames = null) {

                                                    LongVariable

                                                    Since: 0.2

                                                    Detects when a field, formal or local variable is declared with a long name.

                                                    Example

                                                    class Something {
                                                        protected $reallyLongIntName = -3; // VIOLATION - Field
                                                        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                                            $otherReallyLongName = -5; // VIOLATION - Local
                                                            for ($interestingIntIndex = 0; // VIOLATION - For
                                                                 $interestingIntIndex < 10;
                                                                 $interestingIntIndex++ ) {
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/naming.html#longvariable

                                                    Avoid excessively long variable names like $objPgSqlDatabaseResult. Keep variable name length under 20.
                                                    Open

                                                                $objPgSqlDatabaseResult = new QPostgreSqlDatabaseResult($objResult, $this);

                                                    LongVariable

                                                    Since: 0.2

                                                    Detects when a field, formal or local variable is declared with a long name.

                                                    Example

                                                    class Something {
                                                        protected $reallyLongIntName = -3; // VIOLATION - Field
                                                        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                                            $otherReallyLongName = -5; // VIOLATION - Local
                                                            for ($interestingIntIndex = 0; // VIOLATION - For
                                                                 $interestingIntIndex < 10;
                                                                 $interestingIntIndex++ ) {
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/naming.html#longvariable

                                                    Avoid excessively long variable names like $strReferenceTableName. Keep variable name length under 20.
                                                    Open

                                                                    $strReferenceTableName = $strTokenArray[2];

                                                    LongVariable

                                                    Since: 0.2

                                                    Detects when a field, formal or local variable is declared with a long name.

                                                    Example

                                                    class Something {
                                                        protected $reallyLongIntName = -3; // VIOLATION - Field
                                                        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                                            $otherReallyLongName = -5; // VIOLATION - Local
                                                            for ($interestingIntIndex = 0; // VIOLATION - For
                                                                 $interestingIntIndex < 10;
                                                                 $interestingIntIndex++ ) {
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/naming.html#longvariable

                                                    Avoid excessively long variable names like $strReferenceColumnNameArray. Keep variable name length under 20.
                                                    Open

                                                                    $strReferenceColumnNameArray = $this->ParseColumnNameArrayFromKeyDefinition($strTokenArray[3]);

                                                    LongVariable

                                                    Since: 0.2

                                                    Detects when a field, formal or local variable is declared with a long name.

                                                    Example

                                                    class Something {
                                                        protected $reallyLongIntName = -3; // VIOLATION - Field
                                                        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                                            $otherReallyLongName = -5; // VIOLATION - Local
                                                            for ($interestingIntIndex = 0; // VIOLATION - For
                                                                 $interestingIntIndex < 10;
                                                                 $interestingIntIndex++ ) {
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/naming.html#longvariable

                                                    Avoid variables with short names like $s. Configured minimum length is 3.
                                                    Open

                                                                    return $strToReturn . $s;

                                                    ShortVariable

                                                    Since: 0.2

                                                    Detects when a field, local, or parameter has a very short name.

                                                    Example

                                                    class Something {
                                                        private $q = 15; // VIOLATION - Field
                                                        public static function main( array $as ) { // VIOLATION - Formal
                                                            $r = 20 + $this->q; // VIOLATION - Local
                                                            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                                                $r += $this->q;
                                                            }
                                                        }
                                                    }

                                                    Source https://phpmd.org/rules/naming.html#shortvariable

                                                    Constant Adapter should be defined in uppercase
                                                    Open

                                                            const Adapter = 'PostgreSQL Database Adapter';

                                                    ConstantNamingConventions

                                                    Since: 0.2

                                                    Class/Interface constant names should always be defined in uppercase.

                                                    Example

                                                    class Foo {
                                                        const MY_NUM = 0; // ok
                                                        const myTest = ""; // fail
                                                    }

                                                    Source https://phpmd.org/rules/naming.html#constantnamingconventions

                                                    The method Connect is not named in camelCase.
                                                    Open

                                                            public function Connect() {
                                                                // Lookup Adapter-Specific Connection Properties
                                                                $strServer = $this->Server;
                                                                $strName = $this->Database;
                                                                $strUsername = $this->Username;

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method ExecuteQuery is not named in camelCase.
                                                    Open

                                                            protected function ExecuteQuery($strQuery) {
                                                                // Perform the Query
                                                                $objResult = pg_query($this->objPgSql, $strQuery);
                                                                if (!$objResult)
                                                                    throw new QPostgreSqlDatabaseException(pg_last_error(), 0, $strQuery);

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method ExecuteNonQuery is not named in camelCase.
                                                    Open

                                                            protected function ExecuteNonQuery($strNonQuery) {
                                                                // Perform the Query
                                                                $objResult = pg_query($this->objPgSql, $strNonQuery);
                                                                if (!$objResult)
                                                                    throw new QPostgreSqlDatabaseException(pg_last_error(), 0, $strNonQuery);

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method GetForeignKeysForTable is not named in camelCase.
                                                    Open

                                                            public function GetForeignKeysForTable($strTableName) {
                                                                $objForeignKeyArray = array();
                                                                
                                                                // Use Query to pull the FKs
                                                                $strQuery = sprintf('

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method FetchArray is not named in camelCase.
                                                    Open

                                                            public function FetchArray() {
                                                                return pg_fetch_array($this->objPgSqlResult);
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method GetColumn is not named in camelCase.
                                                    Open

                                                            public function GetColumn($strColumnName, $strColumnType = null) {
                                                                if (!isset($this->strColumnArray[$strColumnName])) {
                                                                    return null;
                                                                }
                                                                $strColumnValue = $this->strColumnArray[$strColumnName];

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method GetIndexesForTable is not named in camelCase.
                                                    Open

                                                            public function GetIndexesForTable($strTableName) {
                                                                $objIndexArray = array();
                                                                
                                                                $objResult = $this->Query(sprintf('
                                                                    SELECT 

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method CountFields is not named in camelCase.
                                                    Open

                                                            public function CountFields() {
                                                                return pg_num_fields($this->objPgSqlResult);
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method SqlLimitVariablePrefix is not named in camelCase.
                                                    Open

                                                            public function SqlLimitVariablePrefix($strLimitInfo) {
                                                                // PostgreSQL uses Limit by Suffixes (via a LIMIT clause)
                                                                // Prefix is not used, therefore, return null
                                                                return null;
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method GetFieldsForTable is not named in camelCase.
                                                    Open

                                                            public function GetFieldsForTable($strTableName) {
                                                                $strTableName = $this->SqlVariable($strTableName);
                                                                $strQuery = sprintf('
                                                                    SELECT 
                                                                        columns.table_name,

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method GetTables is not named in camelCase.
                                                    Open

                                                            public function GetTables() {
                                                                $objResult = $this->Query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = current_schema() AND TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME ASC");
                                                                $strToReturn = array();
                                                                while ($strRowArray = $objResult->FetchRow())
                                                                    array_push($strToReturn, $strRowArray[0]);

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method SqlLimitVariableSuffix is not named in camelCase.
                                                    Open

                                                            public function SqlLimitVariableSuffix($strLimitInfo) {
                                                                // Setup limit suffix (if applicable) via a LIMIT clause 
                                                                if (strlen($strLimitInfo)) {
                                                                    if (strpos($strLimitInfo, ';') !== false)
                                                                        throw new Exception('Invalid Semicolon in LIMIT Info');

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method InsertId is not named in camelCase.
                                                    Open

                                                            public function InsertId($strTableName = null, $strColumnName = null) {
                                                                $strQuery = sprintf('
                                                                    SELECT currval(pg_get_serial_sequence(%s, %s))
                                                                ', $this->SqlVariable($strTableName), $this->SqlVariable($strColumnName));
                                                                

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method ParseColumnNameArrayFromKeyDefinition is not named in camelCase.
                                                    Open

                                                            private function ParseColumnNameArrayFromKeyDefinition($strKeyDefinition) {
                                                                $strKeyDefinition = trim($strKeyDefinition);
                                                                
                                                                // Get rid of the opening "(" and the closing ")"
                                                                $intPosition = strpos($strKeyDefinition, '(');

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method ColumnExists is not named in camelCase.
                                                    Open

                                                            public function ColumnExists($strColumnName) {
                                                                return array_key_exists($strColumnName, $this->strColumnArray);
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method InsertOrUpdate is not named in camelCase.
                                                    Open

                                                            public function InsertOrUpdate($strTable, $mixColumnsAndValuesArray, $strPKNames = null) {
                                                                $strEscapedArray = $this->EscapeIdentifiersAndValues($mixColumnsAndValuesArray);
                                                                $strColumns = array_keys($strEscapedArray);
                                                                $strUpdateStatement = '';
                                                                foreach ($strEscapedArray as $strColumn => $strValue) {

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method ResolveBooleanValue is not named in camelCase.
                                                    Open

                                                            public function ResolveBooleanValue ($mixValue) {
                                                                if ($mixValue == 'f') {
                                                                    return false;
                                                                } elseif ($mixValue == 't') {
                                                                    return true;

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method FetchField is not named in camelCase.
                                                    Open

                                                            public function FetchField() {
                                                                return null;  // Not implemented
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method ExecuteTransactionBegin is not named in camelCase.
                                                    Open

                                                            protected function ExecuteTransactionBegin() {
                                                                $this->NonQuery('BEGIN;');
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method ExecuteTransactionRollBack is not named in camelCase.
                                                    Open

                                                            protected function ExecuteTransactionRollBack() {
                                                                $this->NonQuery('ROLLBACK;');
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method Close is not named in camelCase.
                                                    Open

                                                            public function Close() {
                                                                pg_free_result($this->objPgSqlResult);
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method GetColumnNameArray is not named in camelCase.
                                                    Open

                                                            public function GetColumnNameArray() {
                                                                return $this->strColumnArray;
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method SqlSortByVariable is not named in camelCase.
                                                    Open

                                                            public function SqlSortByVariable($strSortByInfo) {
                                                                // Setup sorting information (if applicable) via a ORDER BY clause
                                                                if (strlen($strSortByInfo)) {
                                                                    if (strpos($strSortByInfo, ';') !== false)
                                                                        throw new Exception('Invalid Semicolon in ORDER BY Info');

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method CountRows is not named in camelCase.
                                                    Open

                                                            public function CountRows() {
                                                                return pg_num_rows($this->objPgSqlResult);
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method SqlVariable is not named in camelCase.
                                                    Open

                                                            public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false) {
                                                                // Are we SqlVariabling a BOOLEAN value?
                                                                if (is_bool($mixData)) {
                                                                    // Yes
                                                                    if ($blnIncludeEquality) {

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method Close is not named in camelCase.
                                                    Open

                                                            public function Close() {
                                                                pg_close($this->objPgSql);
                                                    
                                                                // Update Connected Flag
                                                                $this->blnConnectedFlag = false;

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method FetchRow is not named in camelCase.
                                                    Open

                                                            public function FetchRow() {
                                                                return pg_fetch_row($this->objPgSqlResult);
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method FetchFields is not named in camelCase.
                                                    Open

                                                            public function FetchFields() {
                                                                return null;  // Not implemented
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method ExecuteTransactionCommit is not named in camelCase.
                                                    Open

                                                            protected function ExecuteTransactionCommit() {
                                                                $this->NonQuery('COMMIT;');
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method GetRows is not named in camelCase.
                                                    Open

                                                            public function GetRows() {
                                                                $objDbRowArray = array();
                                                                while ($objDbRow = $this->GetNextRow())
                                                                    array_push($objDbRowArray, $objDbRow);
                                                                return $objDbRowArray;

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method ExplainStatement is not named in camelCase.
                                                    Open

                                                            public function ExplainStatement($sql) {
                                                                return $this->Query("EXPLAIN " . $sql);
                                                            }

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    The method GetNextRow is not named in camelCase.
                                                    Open

                                                            public function GetNextRow() {
                                                                $strColumnArray = $this->FetchArray();
                                                                
                                                                if ($strColumnArray)
                                                                    return new QPostgreSqlDatabaseRow($strColumnArray);

                                                    CamelCaseMethodName

                                                    Since: 0.2

                                                    It is considered best practice to use the camelCase notation to name methods.

                                                    Example

                                                    class ClassName {
                                                        public function get_name() {
                                                        }
                                                    }

                                                    Source

                                                    There are no issues that match your filters.

                                                    Category
                                                    Status