diff --git a/.gitignore b/.gitignore index 1c4903b..d76842d 100644 --- a/.gitignore +++ b/.gitignore @@ -148,3 +148,6 @@ docs/phpdoc* .project all_tests build/.phpunit.result.cache +.phpunit.cache +.php-cs-fixer.cache +tools/phpDocumentor diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..e9c974e --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,524 @@ +in([ + __DIR__ . '/src', + __DIR__ . '/tests', + __DIR__ . '/tools', + ]) + ->exclude([ + 'vendor', + ]); + +return (new Config()) + ->setRiskyAllowed(TRUE) + ->setFinder($finder) + ->setIndent(' ') + ->setRules([ + 'align_multiline_comment' => false, + 'array_indentation' => true, + 'array_push' => true, + 'array_syntax' => ['syntax' => 'short'], + 'assign_null_coalescing_to_coalesce_equal' => true, + 'backtick_to_shell_exec' => true, + 'binary_operator_spaces' => [ + 'default' => 'single_space', + 'operators' => [ + '=' => NULL, + '&' => NULL, + ] + ], + 'blank_line_after_namespace' => true, + 'blank_line_after_opening_tag' => false, + 'blank_line_before_statement' => [ + 'statements' => [ + // 'case', + 'continue', + 'declare', + 'default', + 'do', + 'exit', + 'for', + 'foreach', + 'goto', + 'return', + 'switch', + 'throw', + 'try', + 'while', + 'yield', + 'yield_from', + ], + ], + 'braces' => [ + 'allow_single_line_anonymous_class_with_empty_body' => true, + 'allow_single_line_closure' => true, + 'position_after_anonymous_constructs' => 'same', + 'position_after_control_structures' => 'next', + 'position_after_functions_and_oop_constructs' => 'next', + ], + 'cast_spaces' => ['space' => 'single'], + 'class_attributes_separation' => [ + 'elements' => [ + 'const' => 'none', + 'property' => 'none', + 'method' => 'one', + 'trait_import' => 'none', + ], + ], + 'class_definition' => [ + 'multi_line_extends_each_single_line' => true, + 'single_item_single_line' => true, + 'single_line' => true, + 'space_before_parenthesis' => true, + ], + 'class_reference_name_casing' => true, + 'clean_namespace' => true, + 'combine_consecutive_issets' => true, + 'combine_consecutive_unsets' => true, + 'combine_nested_dirname' => true, + 'comment_to_phpdoc' => [ + 'ignored_tags' => [ + 'todo', + 'codeCoverageIgnore', + 'codeCoverageIgnoreStart', + 'codeCoverageIgnoreEnd', + 'phpstan-ignore-line', + 'phpstan-ignore-next-line', + ], + ], + 'compact_nullable_typehint' => true, + 'concat_space' => ['spacing' => 'one'], + 'constant_case' => ['case' => 'upper'], + 'control_structure_continuation_position' => ['position' => 'next_line'], + 'date_time_immutable' => false, + 'declare_equal_normalize' => ['space' => 'none'], + 'declare_parentheses' => true, + 'declare_strict_types' => true, + 'dir_constant' => true, + 'doctrine_annotation_array_assignment' => false, + 'doctrine_annotation_braces' => false, + 'doctrine_annotation_indentation' => false, + 'doctrine_annotation_spaces' => false, + 'echo_tag_syntax' => [ + 'format' => 'short', + 'long_function' => 'echo', + 'shorten_simple_statements_only' => false, + ], + 'elseif' => true, + 'empty_loop_body' => ['style' => 'braces'], + 'empty_loop_condition' => ['style' => 'while'], + 'encoding' => true, + 'error_suppression' => [ + 'mute_deprecation_error' => true, + 'noise_remaining_usages' => false, + 'noise_remaining_usages_exclude' => [], + ], + 'escape_implicit_backslashes' => [ + 'double_quoted' => false, + 'heredoc_syntax' => false, + 'single_quoted' => false, + ], + 'explicit_indirect_variable' => false, + 'explicit_string_variable' => false, + 'final_class' => false, + 'final_internal_class' => [ + 'annotation_exclude' => ['@no-final'], + 'annotation_include' => ['@internal'], + 'consider_absent_docblock_as_internal_class' => false, + ], + 'final_public_method_for_abstract_class' => false, + 'fopen_flag_order' => true, + 'fopen_flags' => ['b_mode' => true], + 'full_opening_tag' => true, + 'fully_qualified_strict_types' => true, + 'function_declaration' => ['closure_function_spacing' => 'one'], + 'function_to_constant' => [ + 'functions' => [ + 'get_called_class', + 'get_class', + 'get_class_this', + 'php_sapi_name', + 'phpversion', + 'pi', + ], + ], + 'function_typehint_space' => true, + 'general_phpdoc_annotation_remove' => false, + 'general_phpdoc_tag_rename' => false, + 'get_class_to_class_keyword' => false, + 'global_namespace_import' => [ + 'import_constants' => true, + 'import_functions' => true, + 'import_classes' => true, + ], + 'group_import' => true, + 'header_comment' => false, // false by default + // 'heredoc_indentation' => ['indentation' => 'start_plus_one'], + 'heredoc_to_nowdoc' => true, + 'implode_call' => true, + 'include' => true, + 'increment_style' => ['style' => 'post'], + 'indentation_type' => true, + 'integer_literal_case' => true, + 'is_null' => true, + 'lambda_not_used_import' => true, + 'line_ending' => true, + 'linebreak_after_opening_tag' => false, + 'list_syntax' => ['syntax' => 'short'], + 'logical_operators' => true, + 'lowercase_cast' => true, + 'lowercase_keywords' => true, + 'lowercase_static_reference' => true, + 'magic_constant_casing' => true, + 'magic_method_casing' => true, + 'mb_str_functions' => false, + 'method_argument_space' => [ + 'after_heredoc' => false, + 'keep_multiple_spaces_after_comma' => false, + 'on_multiline' => 'ensure_fully_multiline', + ], + 'method_chaining_indentation' => true, + 'modernize_strpos' => false, // requires 8.0+ + 'modernize_types_casting' => true, + 'multiline_comment_opening_closing' => true, + 'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'], + 'native_constant_invocation' => false, + 'native_function_casing' => true, + 'native_function_invocation' => false, + 'native_function_type_declaration_casing' => true, + 'new_with_braces' => false, + 'no_alias_functions' => ['sets' => ['@all']], + 'no_alias_language_construct_call' => true, + 'no_alternative_syntax' => ['fix_non_monolithic_code' => false], + 'no_binary_string' => true, + 'no_blank_lines_after_class_opening' => true, + 'no_blank_lines_after_phpdoc' => true, + 'no_blank_lines_before_namespace' => false, // conflicts with `single_blank_line_before_namespace` + 'no_break_comment' => ['comment_text' => 'no break'], + 'no_closing_tag' => true, + 'no_empty_comment' => true, + 'no_empty_phpdoc' => true, + 'no_empty_statement' => true, + 'no_extra_blank_lines' => ['tokens' => ['extra']], + 'no_homoglyph_names' => true, + 'no_leading_import_slash' => true, + 'no_leading_namespace_whitespace' => true, + 'no_mixed_echo_print' => ['use' => 'echo'], + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_null_property_initialization' => true, + 'no_short_bool_cast' => true, + 'no_singleline_whitespace_before_semicolons' => true, + 'no_space_around_double_colon' => true, + 'no_spaces_after_function_name' => true, + 'no_spaces_around_offset' => ['positions' => ['inside', 'outside']], + 'no_spaces_inside_parenthesis' => true, + 'no_superfluous_elseif' => true, + 'no_superfluous_phpdoc_tags' => [ + 'allow_mixed' => true, + 'allow_unused_params' => true, + 'remove_inheritdoc' => false, + ], + 'no_trailing_comma_in_singleline' => true, + 'no_trailing_whitespace' => true, + 'no_trailing_whitespace_in_comment' => true, + 'no_trailing_whitespace_in_string' => true, + 'no_unneeded_control_parentheses' => [ + 'statements' => [ + 'break', + 'clone', + 'continue', + 'echo_print', + 'return', + 'switch_case', + 'yield', + ], + ], + 'no_unneeded_curly_braces' => ['namespaces' => true], + 'no_unneeded_final_method' => ['private_methods' => true], + 'no_unneeded_import_alias' => true, + 'no_unreachable_default_argument_value' => true, + 'no_unset_cast' => true, + 'no_unset_on_property' => false, + 'no_unused_imports' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'no_useless_sprintf' => true, + 'no_whitespace_before_comma_in_array' => ['after_heredoc' => true], + 'no_whitespace_in_blank_line' => true, + 'non_printable_character' => ['use_escape_sequences_in_strings' => true], + 'normalize_index_brace' => true, + 'not_operator_with_space' => true, + 'not_operator_with_successor_space' => true, + 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true], + 'object_operator_without_whitespace' => true, + 'operator_linebreak' => ['only_booleans' => true, 'position' => 'beginning'], + 'ordered_class_elements' => [ + 'order' => [ + 'use_trait', + 'case', + 'constant_public', + 'constant_protected', + 'constant_private', + 'property_public', + 'property_protected', + 'property_private', + 'construct', + 'destruct', + 'magic', + ], + 'sort_algorithm' => 'none', + ], + 'ordered_imports' => [ + 'sort_algorithm' => 'alpha', + 'imports_order' => ['class', 'function', 'const'], + ], + 'ordered_interfaces' => false, + 'ordered_traits' => false, + 'php_unit_construct' => [ + 'assertions' => [ + 'assertSame', + 'assertEquals', + 'assertNotEquals', + 'assertNotSame', + ], + ], + 'php_unit_dedicate_assert' => ['target' => 'newest'], + 'php_unit_dedicate_assert_internal_type' => ['target' => 'newest'], + 'php_unit_expectation' => ['target' => 'newest'], + 'php_unit_fqcn_annotation' => true, + 'php_unit_internal_class' => ['types' => ['final']], + 'php_unit_method_casing' => ['case' => 'camel_case'], + 'php_unit_mock' => ['target' => 'newest'], + 'php_unit_mock_short_will_return' => true, + 'php_unit_namespaced' => ['target' => 'newest'], + 'php_unit_no_expectation_annotation' => [ + 'target' => 'newest', + 'use_class_const' => true, + ], + 'php_unit_set_up_tear_down_visibility' => true, + 'php_unit_size_class' => false, +// 'php_unit_strict' => [ +// 'assertions' => [ +// 'assertAttributeEquals', +// 'assertAttributeNotEquals', +// 'assertEquals', +// 'assertNotEquals', +// ], +// ], + 'php_unit_test_annotation' => ['style' => 'prefix'], + 'php_unit_test_case_static_method_calls' => [ + 'call_type' => 'this', + 'methods' => [], + ], + 'php_unit_test_class_requires_covers' => false, + 'phpdoc_add_missing_param_annotation' => ['only_untyped' => true], + 'phpdoc_align' => [ + 'align' => 'left' + ], + 'phpdoc_annotation_without_dot' => false, + 'phpdoc_indent' => true, + 'phpdoc_inline_tag_normalizer' => [ + 'tags' => [ + 'example', + 'id', + 'internal', + 'inheritdoc', + 'inheritdocs', + 'link', + 'source', + 'toc', + 'tutorial', + ], + ], + 'phpdoc_line_span' => [ + 'const' => 'multi', + 'method' => 'multi', + 'property' => 'multi', + ], + 'phpdoc_no_access' => true, + 'phpdoc_no_empty_return' => false, + 'phpdoc_no_package' => false, + 'phpdoc_no_useless_inheritdoc' => true, + 'phpdoc_order' => true, + 'phpdoc_order_by_value' => [ + 'annotations' => [ + 'author', + 'covers', + 'coversNothing', + 'dataProvider', + 'depends', + 'group', + 'internal', + 'method', + 'property', + 'property-read', + 'property-write', + 'requires', + 'throws', + 'uses', + ], + ], + 'phpdoc_return_self_reference' => [ + 'replacements' => [ + 'this' => '$this', + '@this' => '$this', + '$self' => 'self', + '@self' => 'self', + '$static' => 'static', + '@static' => 'static', + ], + ], + 'phpdoc_scalar' => [ + 'types' => [ + 'boolean', + 'callback', + 'double', + 'integer', + 'real', + 'str', + ], + ], + 'phpdoc_separation' => false, + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_summary' => false, + 'phpdoc_tag_casing' => ['tags' => ['inheritDoc']], + 'phpdoc_tag_type' => ['tags' => ['inheritDoc' => 'inline']], + 'phpdoc_to_comment' => false, + 'phpdoc_to_param_type' => false, + 'phpdoc_to_property_type' => false, + 'phpdoc_to_return_type' => false, + 'phpdoc_trim' => true, + 'phpdoc_trim_consecutive_blank_line_separation' => true, + 'phpdoc_types' => ['groups' => ['simple', 'alias', 'meta']], + 'phpdoc_types_order' => [ + 'null_adjustment' => 'always_last', + 'sort_algorithm' => 'alpha', + ], + 'phpdoc_var_annotation_correct_order' => true, + 'phpdoc_var_without_name' => true, + 'pow_to_exponentiation' => true, + 'protected_to_private' => true, + 'psr_autoloading' => ['dir' => null], + 'random_api_migration' => [ + 'replacements' => [ + 'getrandmax' => 'mt_getrandmax', + 'rand' => 'mt_rand', + 'srand' => 'mt_srand', + ], + ], + 'regular_callable_call' => true, + 'return_assignment' => true, + 'return_type_declaration' => ['space_before' => 'none'], + 'self_accessor' => false, + 'self_static_accessor' => true, + 'semicolon_after_instruction' => false, + 'set_type_to_cast' => true, + 'short_scalar_cast' => true, + 'simple_to_complex_string_variable' => true, + 'simplified_if_return' => true, + 'simplified_null_return' => false, + 'single_blank_line_at_eof' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => ['elements' => ['const', 'property']], + 'single_import_per_statement' => false, + 'single_line_after_imports' => true, + 'single_line_comment_style' => ['comment_types' => ['asterisk', 'hash']], + 'single_line_throw' => false, + 'single_quote' => ['strings_containing_single_quote_chars' => false], + 'single_space_after_construct' => [ + 'constructs' => [ + 'abstract', + 'as', + 'attribute', + 'break', + 'case', + 'catch', + 'class', + 'clone', + 'comment', + 'const', + 'const_import', + 'continue', + 'do', + 'echo', + 'else', + 'elseif', + 'extends', + 'final', + 'finally', + 'for', + 'foreach', + 'function', + 'function_import', + 'global', + 'goto', + 'if', + 'implements', + 'include', + 'include_once', + 'instanceof', + 'insteadof', + 'interface', + 'match', + 'named_argument', + 'new', + 'open_tag_with_echo', + 'php_doc', + 'php_open', + 'print', + 'private', + 'protected', + 'public', + 'require', + 'require_once', + 'return', + 'static', + 'throw', + 'trait', + 'try', + 'use', + 'use_lambda', + 'use_trait', + 'var', + 'while', + 'yield', + 'yield_from', + ], + ], + 'single_trait_insert_per_statement' => true, + 'space_after_semicolon' => ['remove_in_empty_for_expressions' => true], + 'standardize_increment' => true, + 'standardize_not_equals' => true, + 'static_lambda' => true, + 'strict_comparison' => true, + 'strict_param' => true, + 'string_length_to_empty' => true, + 'string_line_ending' => true, + 'switch_case_semicolon_to_colon' => true, + 'switch_case_space' => true, + 'switch_continue_to_break' => true, + 'ternary_operator_spaces' => true, + 'ternary_to_elvis_operator' => true, + 'ternary_to_null_coalescing' => true, + 'trailing_comma_in_multiline' => [ + 'after_heredoc' => true, + 'elements' => ['arrays'], + ], + 'trim_array_spaces' => true, + 'types_spaces' => ['space' => 'none'], + 'unary_operator_spaces' => false, + 'use_arrow_functions' => true, + 'visibility_required' => ['elements' => ['const', 'method', 'property']], + 'void_return' => false, // changes method signature + 'whitespace_after_comma_in_array' => true, + 'yoda_style' => [ + 'equal' => false, + 'identical' => null, + 'less_and_greater' => false, + 'always_move_variable' => false, + ], + ]); diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index c8221ee..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,25 +0,0 @@ -imports: - - php - -tools: - external_code_coverage: - timeout: 1000 - # PHP - - # Don't like PSR standards, not going to get messages for them! - php_code_sniffer: false - - php_sim: true - # Can't be used with similarity analyzer - php_cpd: false - - php_mess_detector: true - php_pdepend: true - php_loc: true - php_analyzer: - config: - metrics_lack_of_cohesion_methods: - enabled: true - doc_comment_fixes: - enabled: true - php_hhvm: true \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ae2522c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -dist: bionic -os: linux - -arch: - - amd64 - - arm64 - - ppc64le - -language: php - -services: - - mysql - - postgresql - -php: - - nightly -# - '8.0' - - '8.1' - - '8.2' -# - '7.4' -# - '8.0' - - -before_script: - - psql -c 'DROP DATABASE IF EXISTS test;' -U postgres - - psql -c 'create database test;' -U postgres - - mysql -e 'create database IF NOT EXISTS test;' - - composer install --ignore-platform-reqs - -script: - - mkdir -p build/logs - - cd build - - ../vendor/bin/phpunit -c phpunit.xml --coverage-clover build/logs/clover.xml - - cd ../ - -after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml - -jobs: - allow_failures: - - arch: ppc64le - - php: nightly diff --git a/README.md b/README.md index 7e49c4b..ab19d95 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ A query builder/database abstraction layer, using prepared statements for security. -[![Code Coverage](https://scrutinizer-ci.com/g/aviat4ion/Query/badges/coverage.png?b=develop)](https://scrutinizer-ci.com/g/aviat4ion/Query/?branch=develop) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/aviat4ion/Query/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/aviat4ion/Query/?branch=develop) [![Latest Stable Version](https://poser.pugx.org/aviat/query/v/stable.png)](https://packagist.org/packages/aviat/query) [![Total Downloads](https://poser.pugx.org/aviat/query/downloads.png)](https://packagist.org/packages/aviat/query) [![Latest Unstable Version](https://poser.pugx.org/aviat/query/v/unstable.png)](https://packagist.org/packages/aviat/query) diff --git a/RoboFile.php b/RoboFile.php deleted file mode 100644 index 3427c99..0000000 --- a/RoboFile.php +++ /dev/null @@ -1,305 +0,0 @@ -prepare(); - $this->lint(); - $this->phploc(TRUE); - $this->phpcs(TRUE); - $this->phpmd(TRUE); - $this->phpcpdReport(); - } - - /** - * Run all tests, generate coverage, generate docs, generate code statistics - */ - public function build(): void - { - $this->analyze(); - $this->coverage(); - $this->docs(); - } - - /** - * Cleanup temporary files - */ - public function clean(): void - { - // So the task doesn't complain, - // make any 'missing' dirs to cleanup - array_map(static function ($dir) { - if ( ! is_dir($dir)) - { - `mkdir -p {$dir}`; - } - }, $this->cleanDirs); - - $this->_cleanDir($this->cleanDirs); - $this->_deleteDir($this->cleanDirs); - } - - /** - * Run unit tests and generate coverage reports - */ - public function coverage(): void - { - $this->_run(['phpdbg -qrr -- vendor/bin/phpunit -c build']); - } - - /** - * Generate documentation with phpdox - */ - public function docs(): void - { - $this->_run(['tools/phpdox/vendor/bin/phpdox']); - } - - /** - * Verify that source files are valid - */ - public function lint(): void - { - $files = $this->getAllSourceFiles(); - - $chunks = array_chunk($files, (int)shell_exec('getconf _NPROCESSORS_ONLN')); - - foreach($chunks as $chunk) - { - $this->parallelLint($chunk); - } - } - - /** - * Run the phpcs tool - * - * @param bool $report - if true, generates reports instead of direct output - */ - public function phpcs(bool $report = FALSE): void - { - $dir = __DIR__; - - $report_cmd_parts = [ - 'tools/vendor/bin/phpcs', - "--standard=./build/CodeIgniter", - "--report-checkstyle=./build/logs/phpcs.xml", - ]; - - $normal_cmd_parts = [ - 'tools/vendor/bin/phpcs', - "--standard=./build/CodeIgniter", - ]; - - $cmd_parts = ($report) ? $report_cmd_parts : $normal_cmd_parts; - - $this->_run($cmd_parts); - } - - public function phpmd(bool $report = FALSE): void - { - $report_cmd_parts = [ - 'tools/vendor/bin/phpmd', - './src', - 'xml', - 'cleancode,codesize,controversial,design,naming,unusedcode', - '--exclude ParallelAPIRequest', - '--reportfile ./build/logs/phpmd.xml' - ]; - - $normal_cmd_parts = [ - 'tools/vendor/bin/phpmd', - './src', - 'ansi', - 'cleancode,codesize,controversial,design,naming,unusedcode', - '--exclude ParallelAPIRequest' - ]; - - $cmd_parts = ($report) ? $report_cmd_parts : $normal_cmd_parts; - - $this->_run($cmd_parts); - } - - /** - * Run the phploc tool - * - * @param bool $report - if true, generates reports instead of direct output - */ - public function phploc($report = FALSE): void - { - // Command for generating reports - $report_cmd_parts = [ - 'tools/vendor/bin/phploc', - '--count-tests', - '--log-csv=build/logs/phploc.csv', - '--log-xml=build/logs/phploc.xml', - 'src', - 'tests' - ]; - - // Command for generating direct output - $normal_cmd_parts = [ - 'tools/vendor/bin/phploc', - '--count-tests', - 'src', - 'tests' - ]; - - $cmd_parts = ($report) ? $report_cmd_parts : $normal_cmd_parts; - - $this->_run($cmd_parts); - } - - /** - * Create temporary directories - */ - public function prepare(): void - { - array_map([$this, '_mkdir'], $this->taskDirs); - } - - /** - * Lint php files and run unit tests - */ - public function test(): void - { - $this->lint(); - $this->taskPhpUnit() - ->configFile('build/phpunit.xml') - ->run(); - $this->_run(["php tests/index.php"]); - } - - /** - * Watches for file updates, and automatically runs appropriate actions - */ - public function watch(): void - { - $this->taskWatch() - ->monitor('composer.json', function() { - $this->taskComposerUpdate()->run(); - }) - ->monitor('src', function () { - $this->taskExec('test')->run(); - }) - ->monitor('tests', function () { - $this->taskExec('test')->run(); - }) - ->run(); - } - - /** - * Get the total list of source files, including tests - * - * @return array - */ - protected function getAllSourceFiles(): array - { - $files = array_merge( - glob_recursive('build/*.php'), - glob_recursive('src/*.php'), - glob_recursive('tests/*.php'), - glob('*.php') - ); - - sort($files); - - return $files; - } - - /** - * Run php's linter in one parallel task for the passed chunk - * - * @param array $chunk - */ - protected function parallelLint(array $chunk): void - { - $task = $this->taskParallelExec() - ->timeout(5) - ->printed(FALSE); - - foreach($chunk as $file) - { - $task = $task->process("php -l {$file}"); - } - - $task->run(); - } - - /** - * Generate copy paste detector report - */ - protected function phpcpdReport(): void - { - $cmd_parts = [ - 'tools/vendor/bin/phpcpd', - '--log-pmd build/logs/pmd-cpd.xml', - 'src' - ]; - $this->_run($cmd_parts); - } - - /** - * Shortcut for joining an array of command arguments - * and then running it - * - * @param array $cmd_parts - command arguments - * @param string $join_on - what to join the command arguments with - */ - protected function _run(array $cmd_parts, $join_on = ' '): void - { - $this->taskExec(implode($join_on, $cmd_parts))->run(); - } -} diff --git a/apiDocumentation/classes/Query-ConnectionManager.html b/apiDocumentation/classes/Query-ConnectionManager.html index b8a6c3e..f7e0246 100644 --- a/apiDocumentation/classes/Query-ConnectionManager.html +++ b/apiDocumentation/classes/Query-ConnectionManager.html @@ -115,9 +115,9 @@

Connection manager class to manage connections for the @@ -212,9 +212,9 @@ Query method

Private clone method to prevent cloning

@@ -260,9 +260,9 @@ Query method

Prevent serialization of this object

@@ -308,9 +308,9 @@ Query method

Make sure serialize/deserialize doesn't work

@@ -356,9 +356,9 @@ Query method

Parse the passed parameters and return a connection

@@ -375,7 +375,8 @@ Query method

: array<string|int, mixed>|object
- +
+
@@ -400,9 +401,9 @@ Query method

Returns the connection specified by the name given

@@ -419,7 +420,8 @@ Query method

: string = ''
- +
+
@@ -458,9 +460,9 @@ Query method

Return a connection manager instance

@@ -507,9 +509,9 @@ Query method

Parses params into a dsn and option array

@@ -526,7 +528,8 @@ Query method

: array<string|int, mixed>|object
- +
+
diff --git a/apiDocumentation/classes/Query-Drivers-AbstractDriver.html b/apiDocumentation/classes/Query-Drivers-AbstractDriver.html index b077483..1bad725 100644 --- a/apiDocumentation/classes/Query-Drivers-AbstractDriver.html +++ b/apiDocumentation/classes/Query-Drivers-AbstractDriver.html @@ -122,9 +122,9 @@

Base Database class

@@ -422,9 +422,9 @@ the connection/database

Allow invoke to work on table object

@@ -455,19 +455,6 @@ the connection/database -
- Tags - -
-
-
- codeCoverageIgnore -
-
- - -
-
Return values
mixed @@ -497,7 +484,7 @@ the connection/database public - __construct(string $dsn[, string $username = NULL ][, string $password = NULL ][, array<string|int, mixed> $driverOptions = [] ]) : mixed + __construct(string $dsn[, string|null $username = NULL ][, string|null $password = NULL ][, array<string|int, mixed> $driverOptions = [] ]) : mixed
Parameters
@@ -512,7 +499,7 @@ the connection/database
$username - : string + : string|null = NULL
@@ -520,7 +507,7 @@ the connection/database
$password - : string + : string|null = NULL
@@ -557,9 +544,9 @@ the connection/database

Helper method for quote_ident

@@ -576,7 +563,8 @@ the connection/database : mixed
- +
+
@@ -601,9 +589,9 @@ the connection/database

Returns number of rows affected by an INSERT, UPDATE, DELETE type query

@@ -635,9 +623,9 @@ the connection/database

Method to simplify retrieving db results for meta-data queries

@@ -688,9 +676,9 @@ the connection/database

Retrieve column information for the current database table

@@ -733,9 +721,9 @@ the connection/database

Return list of dbs for the current connection, if possible

@@ -767,9 +755,9 @@ the connection/database

Retrieve foreign keys for the table

@@ -812,9 +800,9 @@ the connection/database

Return list of functions for the current database

@@ -861,9 +849,9 @@ the connection/database

Retrieve indexes for the table

@@ -906,9 +894,9 @@ the connection/database

Get the last sql query executed

@@ -940,9 +928,9 @@ the connection/database

Return list of stored procedures for the current database

@@ -1023,9 +1011,9 @@ the connection/database

Return list of sequences for the current database, if they exist

@@ -1057,9 +1045,9 @@ the connection/database

Get the SQL class for the current driver

@@ -1091,9 +1079,9 @@ the connection/database

Retrieves an array of non-user-created tables for @@ -1160,9 +1148,9 @@ the connection/database

Return list of triggers for the current database

@@ -1209,9 +1197,9 @@ the connection/database

Retrieve list of data types for the database

@@ -1243,9 +1231,9 @@ the connection/database

Get the Util class for the current driver

@@ -1277,9 +1265,9 @@ the connection/database

Get the version of the database engine

@@ -1311,9 +1299,9 @@ the connection/database

Return list of views for the current database

@@ -1345,9 +1333,9 @@ the connection/database

Create sql for batch insert

@@ -1398,9 +1386,9 @@ the connection/database

Return the number of rows returned for a SELECT query

@@ -1446,9 +1434,9 @@ the connection/database

Prefixes a table if it is not already prefixed

@@ -1491,9 +1479,9 @@ the connection/database

Create and execute a prepared statement with the provided parameters

@@ -1558,9 +1546,9 @@ the connection/database

Simplifies prepared statements for database queries

@@ -1611,9 +1599,9 @@ the connection/database

Surrounds the string with the databases identifier escape characters

@@ -1656,9 +1644,9 @@ the connection/database

Quote database table name, and set prefix

@@ -1701,9 +1689,9 @@ the connection/database

Generate the returning clause for the current database

@@ -1754,9 +1742,9 @@ the connection/database

Set the last query sql

@@ -1799,9 +1787,9 @@ the connection/database

Set the common table name prefix

@@ -1844,9 +1832,9 @@ the connection/database

Empty the passed table

@@ -1889,9 +1877,9 @@ the connection/database

Creates a batch update, and executes it.

diff --git a/apiDocumentation/classes/Query-Drivers-AbstractSQL.html b/apiDocumentation/classes/Query-Drivers-AbstractSQL.html index a89482f..d9b278e 100644 --- a/apiDocumentation/classes/Query-Drivers-AbstractSQL.html +++ b/apiDocumentation/classes/Query-Drivers-AbstractSQL.html @@ -119,9 +119,9 @@

Parent for database-specific syntax subclasses

@@ -185,9 +185,9 @@

Limit clause

diff --git a/apiDocumentation/classes/Query-Drivers-AbstractUtil.html b/apiDocumentation/classes/Query-Drivers-AbstractUtil.html index 9a0940a..29a62a3 100644 --- a/apiDocumentation/classes/Query-Drivers-AbstractUtil.html +++ b/apiDocumentation/classes/Query-Drivers-AbstractUtil.html @@ -116,9 +116,9 @@

Abstract class defining database / table creation methods

@@ -205,9 +205,9 @@

Save a reference to the connection object for later use

@@ -264,19 +264,6 @@ -
- Tags - -
-
-
- abstract -
-
- - -
-
Return values
string @@ -297,9 +284,9 @@

Return an SQL file with the database table structure

@@ -311,19 +298,6 @@ -
- Tags - -
-
-
- abstract -
-
- - -
-
Return values
string @@ -344,9 +318,9 @@

Convenience public function to generate sql for creating a db table

@@ -413,9 +387,9 @@

Drop the selected table

@@ -458,9 +432,9 @@

Get the driver object for the current connection

diff --git a/apiDocumentation/classes/Query-Drivers-DriverInterface.html b/apiDocumentation/classes/Query-Drivers-DriverInterface.html index 68107d6..58d8869 100644 --- a/apiDocumentation/classes/Query-Drivers-DriverInterface.html +++ b/apiDocumentation/classes/Query-Drivers-DriverInterface.html @@ -385,7 +385,7 @@ the connection/database public - __construct(string $dsn[, string $username = NULL ][, string $password = NULL ][, array<string|int, mixed> $driverOptions = [] ]) : mixed + __construct(string $dsn[, string|null $username = NULL ][, string|null $password = NULL ][, array<string|int, mixed> $driverOptions = [] ]) : mixed
Parameters
@@ -400,7 +400,7 @@ the connection/database
$username - : string + : string|null = NULL
@@ -408,7 +408,7 @@ the connection/database
$password - : string + : string|null = NULL
diff --git a/apiDocumentation/classes/Query-Drivers-Mysql-Driver.html b/apiDocumentation/classes/Query-Drivers-Mysql-Driver.html index 5b8ea23..68b51c3 100644 --- a/apiDocumentation/classes/Query-Drivers-Mysql-Driver.html +++ b/apiDocumentation/classes/Query-Drivers-Mysql-Driver.html @@ -120,9 +120,9 @@

MySQL specific class

@@ -406,9 +406,9 @@ the connection/database

Allow invoke to work on table object

@@ -439,19 +439,6 @@ the connection/database -
- Tags - -
-
-
- codeCoverageIgnore -
-
- - -
-
Return values
mixed @@ -481,7 +468,7 @@ the connection/database public - __construct(string $dsn[, string $username = NULL ][, string $password = NULL ][, array<string|int, mixed> $options = [] ]) : mixed + __construct(string $dsn[, string|null $username = NULL ][, string|null $password = NULL ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
@@ -496,7 +483,7 @@ the connection/database
$username - : string + : string|null = NULL
@@ -504,7 +491,7 @@ the connection/database
$password - : string + : string|null = NULL
@@ -521,19 +508,6 @@ the connection/database
-
- Tags - -
-
-
- codeCoverageIgnore -
-
- - -
-
Return values
mixed @@ -554,9 +528,9 @@ the connection/database

Helper method for quote_ident

@@ -573,7 +547,8 @@ the connection/database : mixed
- +
+
@@ -598,9 +573,9 @@ the connection/database

Returns number of rows affected by an INSERT, UPDATE, DELETE type query

@@ -632,9 +607,9 @@ the connection/database

Method to simplify retrieving db results for meta-data queries

@@ -685,9 +660,9 @@ the connection/database

Retrieve column information for the current database table

@@ -730,9 +705,9 @@ the connection/database

Return list of dbs for the current connection, if possible

@@ -764,9 +739,9 @@ the connection/database

Retrieve foreign keys for the table

@@ -809,9 +784,9 @@ the connection/database

Return list of functions for the current database

@@ -858,9 +833,9 @@ the connection/database

Retrieve indexes for the table

@@ -903,9 +878,9 @@ the connection/database

Get the last sql query executed

@@ -937,9 +912,9 @@ the connection/database

Return list of stored procedures for the current database

@@ -1020,9 +995,9 @@ the connection/database

Return list of sequences for the current database, if they exist

@@ -1054,9 +1029,9 @@ the connection/database

Get the SQL class for the current driver

@@ -1088,9 +1063,9 @@ the connection/database

Retrieves an array of non-user-created tables for @@ -1157,9 +1132,9 @@ the connection/database

Return list of triggers for the current database

@@ -1206,9 +1181,9 @@ the connection/database

Retrieve list of data types for the database

@@ -1240,9 +1215,9 @@ the connection/database

Get the Util class for the current driver

@@ -1274,9 +1249,9 @@ the connection/database

Get the version of the database engine

@@ -1308,9 +1283,9 @@ the connection/database

Return list of views for the current database

@@ -1342,9 +1317,9 @@ the connection/database

Create sql for batch insert

@@ -1395,9 +1370,9 @@ the connection/database

Return the number of rows returned for a SELECT query

@@ -1443,9 +1418,9 @@ the connection/database

Prefixes a table if it is not already prefixed

@@ -1488,9 +1463,9 @@ the connection/database

Create and execute a prepared statement with the provided parameters

@@ -1555,9 +1530,9 @@ the connection/database

Simplifies prepared statements for database queries

@@ -1608,9 +1583,9 @@ the connection/database

Surrounds the string with the databases identifier escape characters

@@ -1653,9 +1628,9 @@ the connection/database

Quote database table name, and set prefix

@@ -1698,9 +1673,9 @@ the connection/database

Generate the returning clause for the current database

@@ -1751,9 +1726,9 @@ the connection/database

Set the last query sql

@@ -1796,9 +1771,9 @@ the connection/database

Set the common table name prefix

@@ -1841,9 +1816,9 @@ the connection/database

Empty the passed table

@@ -1886,9 +1861,9 @@ the connection/database

Creates a batch update, and executes it.

diff --git a/apiDocumentation/classes/Query-Drivers-Mysql-SQL.html b/apiDocumentation/classes/Query-Drivers-Mysql-SQL.html index d63cc0e..dca8729 100644 --- a/apiDocumentation/classes/Query-Drivers-Mysql-SQL.html +++ b/apiDocumentation/classes/Query-Drivers-Mysql-SQL.html @@ -120,9 +120,9 @@

MySQL specific SQL

@@ -273,9 +273,9 @@ table

SQL to show information about columns in a table

@@ -318,9 +318,9 @@ table

Returns sql to list other databases

@@ -352,9 +352,9 @@ table

Get the query plan for the sql query

@@ -397,9 +397,9 @@ table

Get the list of foreign keys for the current @@ -443,9 +443,9 @@ table

Return sql to list functions

@@ -457,19 +457,6 @@ table

-
- Tags - -
-
-
- codeCoverageIgnore -
-
- - -
-
Return values
string @@ -490,9 +477,9 @@ table

Get the list of indexes for the current table

@@ -535,9 +522,9 @@ table

Limit clause

@@ -596,9 +583,9 @@ table

Return sql to list stored procedures

@@ -610,19 +597,6 @@ table

-
- Tags - -
-
-
- codeCoverageIgnore -
-
- - -
-
Return values
string @@ -643,9 +617,9 @@ table

Random ordering keyword

@@ -677,9 +651,9 @@ table

Return sql to list sequences

@@ -711,9 +685,9 @@ table

Overridden in MySQL class

@@ -745,9 +719,9 @@ table

Returns sql to list tables

@@ -790,9 +764,9 @@ table

Returns sql to list triggers

@@ -804,19 +778,6 @@ table

-
- Tags - -
-
-
- codeCoverageIgnore -
-
- - -
-
Return values
string @@ -837,9 +798,9 @@ table

SQL to show list of field types

@@ -871,9 +832,9 @@ table

Returns sql to list views

diff --git a/apiDocumentation/classes/Query-Drivers-Mysql-Util.html b/apiDocumentation/classes/Query-Drivers-Mysql-Util.html index f8bb428..8f1c6be 100644 --- a/apiDocumentation/classes/Query-Drivers-Mysql-Util.html +++ b/apiDocumentation/classes/Query-Drivers-Mysql-Util.html @@ -120,9 +120,9 @@

MySQL-specific backup, import and creation methods

@@ -209,9 +209,9 @@

Save a reference to the connection object for later use

@@ -299,9 +299,9 @@

Create an SQL backup file for the current database's structure

@@ -333,9 +333,9 @@

Convenience public function to generate sql for creating a db table

@@ -402,9 +402,9 @@

Drop the selected table

@@ -447,9 +447,9 @@

Get the driver object for the current connection

diff --git a/apiDocumentation/classes/Query-Drivers-Pgsql-Driver.html b/apiDocumentation/classes/Query-Drivers-Pgsql-Driver.html index 8d6daa7..b7f1c6d 100644 --- a/apiDocumentation/classes/Query-Drivers-Pgsql-Driver.html +++ b/apiDocumentation/classes/Query-Drivers-Pgsql-Driver.html @@ -120,9 +120,9 @@

PostgreSQL specific class

@@ -406,9 +406,9 @@ the connection/database

Allow invoke to work on table object

@@ -439,19 +439,6 @@ the connection/database -
- Tags - -
-
-
- codeCoverageIgnore -
-
- - -
-
Return values
mixed @@ -481,7 +468,7 @@ the connection/database public - __construct(string $dsn[, string $username = NULL ][, string $password = NULL ][, array<string|int, mixed> $options = [] ]) : mixed + __construct(string $dsn[, string|null $username = NULL ][, string|null $password = NULL ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
@@ -496,7 +483,7 @@ the connection/database
$username - : string + : string|null = NULL
@@ -504,7 +491,7 @@ the connection/database
$password - : string + : string|null = NULL
@@ -521,19 +508,6 @@ the connection/database
-
- Tags - -
-
-
- codeCoverageIgnore -
-
- - -
-
Return values
mixed @@ -554,9 +528,9 @@ the connection/database

Helper method for quote_ident

@@ -573,7 +547,8 @@ the connection/database : mixed
- +
+
@@ -598,9 +573,9 @@ the connection/database

Returns number of rows affected by an INSERT, UPDATE, DELETE type query

@@ -632,9 +607,9 @@ the connection/database

Method to simplify retrieving db results for meta-data queries

@@ -685,9 +660,9 @@ the connection/database

Retrieve column information for the current database table

@@ -730,9 +705,9 @@ the connection/database

Return list of dbs for the current connection, if possible

@@ -764,9 +739,9 @@ the connection/database

Retrieve foreign keys for the table

@@ -809,9 +784,9 @@ the connection/database

Return list of functions for the current database

@@ -858,9 +833,9 @@ the connection/database

Retrieve indexes for the table

@@ -903,9 +878,9 @@ the connection/database

Get the last sql query executed

@@ -937,9 +912,9 @@ the connection/database

Return list of stored procedures for the current database

@@ -986,9 +961,9 @@ the connection/database

Get a list of schemas for the current connection

@@ -1020,9 +995,9 @@ the connection/database

Return list of sequences for the current database, if they exist

@@ -1054,9 +1029,9 @@ the connection/database

Get the SQL class for the current driver

@@ -1088,9 +1063,9 @@ the connection/database

Retrieves an array of non-user-created tables for @@ -1157,9 +1132,9 @@ the connection/database

Return list of triggers for the current database

@@ -1206,9 +1181,9 @@ the connection/database

Retrieve list of data types for the database

@@ -1240,9 +1215,9 @@ the connection/database

Get the Util class for the current driver

@@ -1274,9 +1249,9 @@ the connection/database

Get the version of the database engine

@@ -1308,9 +1283,9 @@ the connection/database

Return list of views for the current database

@@ -1342,9 +1317,9 @@ the connection/database

Create sql for batch insert

@@ -1395,9 +1370,9 @@ the connection/database

Return the number of rows returned for a SELECT query

@@ -1443,9 +1418,9 @@ the connection/database

Prefixes a table if it is not already prefixed

@@ -1488,9 +1463,9 @@ the connection/database

Create and execute a prepared statement with the provided parameters

@@ -1555,9 +1530,9 @@ the connection/database

Simplifies prepared statements for database queries

@@ -1608,9 +1583,9 @@ the connection/database

Surrounds the string with the databases identifier escape characters

@@ -1653,9 +1628,9 @@ the connection/database

Quote database table name, and set prefix

@@ -1698,9 +1673,9 @@ the connection/database

Generate the returning clause for the current database

@@ -1751,9 +1726,9 @@ the connection/database

Set the last query sql

@@ -1796,9 +1771,9 @@ the connection/database

Set the common table name prefix

@@ -1841,9 +1816,9 @@ the connection/database

Empty the passed table

@@ -1886,9 +1861,9 @@ the connection/database

Creates a batch update, and executes it.

diff --git a/apiDocumentation/classes/Query-Drivers-Pgsql-SQL.html b/apiDocumentation/classes/Query-Drivers-Pgsql-SQL.html index 04ac021..d6a41c3 100644 --- a/apiDocumentation/classes/Query-Drivers-Pgsql-SQL.html +++ b/apiDocumentation/classes/Query-Drivers-Pgsql-SQL.html @@ -120,9 +120,9 @@

PostgreSQL specific SQL

@@ -273,9 +273,9 @@ table

Return sql to list columns of the specified table

@@ -318,9 +318,9 @@ table

Returns sql to list other databases

@@ -352,9 +352,9 @@ table

Get the query plan for the sql query

@@ -397,9 +397,9 @@ table

Get the list of foreign keys for the current @@ -443,9 +443,9 @@ table

Return sql to list functions

@@ -477,9 +477,9 @@ table

Get the list of indexes for the current table

@@ -522,9 +522,9 @@ table

Limit clause

@@ -583,9 +583,9 @@ table

Return sql to list stored procedures

@@ -617,9 +617,9 @@ table

Random ordering keyword

@@ -651,9 +651,9 @@ table

Return sql to list sequences

@@ -685,9 +685,9 @@ table

Returns sql to list system tables

@@ -719,9 +719,9 @@ table

Returns sql to list tables

@@ -753,9 +753,9 @@ table

Returns sql to list triggers

@@ -787,9 +787,9 @@ table

SQL to show list of field types

@@ -821,9 +821,9 @@ table

Returns sql to list views

diff --git a/apiDocumentation/classes/Query-Drivers-Pgsql-Util.html b/apiDocumentation/classes/Query-Drivers-Pgsql-Util.html index 7d0922f..e7c32a6 100644 --- a/apiDocumentation/classes/Query-Drivers-Pgsql-Util.html +++ b/apiDocumentation/classes/Query-Drivers-Pgsql-Util.html @@ -120,9 +120,9 @@

Postgres-specific backup, import and creation methods

@@ -209,9 +209,9 @@

Save a reference to the connection object for later use

@@ -254,9 +254,9 @@

Create an SQL backup file for the current database's data

@@ -299,9 +299,9 @@

Create an SQL backup file for the current database's structure

@@ -333,9 +333,9 @@

Convenience public function to generate sql for creating a db table

@@ -402,9 +402,9 @@

Drop the selected table

@@ -447,9 +447,9 @@

Get the driver object for the current connection

diff --git a/apiDocumentation/classes/Query-Drivers-SQLInterface.html b/apiDocumentation/classes/Query-Drivers-SQLInterface.html index fb5094b..7b360d9 100644 --- a/apiDocumentation/classes/Query-Drivers-SQLInterface.html +++ b/apiDocumentation/classes/Query-Drivers-SQLInterface.html @@ -112,9 +112,9 @@

Interface for database-specific syntax subclasses

@@ -264,9 +264,9 @@ table

Get information about the columns in the @@ -310,9 +310,9 @@ specified table

Returns sql to list other databases

@@ -344,9 +344,9 @@ specified table

Modify the query to get the query plan

@@ -389,9 +389,9 @@ specified table

Get the list of foreign keys for the current @@ -435,9 +435,9 @@ table

Return sql to list functions

@@ -469,9 +469,9 @@ table

Get the list of indexes for the current table

@@ -514,9 +514,9 @@ table

Get database specific sql for limit clause

@@ -575,9 +575,9 @@ table

Return sql to list stored procedures

@@ -609,9 +609,9 @@ table

Get the sql for random ordering

@@ -643,9 +643,9 @@ table

Return sql to list sequences

@@ -677,9 +677,9 @@ table

Returns sql to list system tables

@@ -711,9 +711,9 @@ table

Returns sql to list tables

@@ -745,9 +745,9 @@ table

Returns sql to list triggers

@@ -779,9 +779,9 @@ table

Return sql to list database field types

@@ -813,9 +813,9 @@ table

Returns sql to list views

diff --git a/apiDocumentation/classes/Query-Drivers-Sqlite-Driver.html b/apiDocumentation/classes/Query-Drivers-Sqlite-Driver.html index bb1bd5b..490a66e 100644 --- a/apiDocumentation/classes/Query-Drivers-Sqlite-Driver.html +++ b/apiDocumentation/classes/Query-Drivers-Sqlite-Driver.html @@ -120,9 +120,9 @@

SQLite specific class

@@ -299,7 +299,7 @@ the connection/database
insertBatch() -  : array<string|int, array<string|int, mixed>>|array<string|int, string>|array<string|int, null> +  : array<string|int, array<string|int, mixed>>|array<string|int, null>|array<string|int, string>
Create sql for batch insert
@@ -406,9 +406,9 @@ the connection/database

Allow invoke to work on table object

@@ -439,19 +439,6 @@ the connection/database -
- Tags - -
-
-
- codeCoverageIgnore -
-
- - -
-
Return values
mixed @@ -472,16 +459,16 @@ the connection/database

Open SQLite Database

public - __construct(string $dsn[, string $user = NULL ][, string $pass = NULL ][, array<string|int, mixed> $driverOptions = [] ]) : mixed + __construct(string $dsn[, string|null $user = NULL ][, string|null $pass = NULL ][, array<string|int, mixed> $driverOptions = [] ]) : mixed
Parameters
@@ -496,7 +483,7 @@ the connection/database
$user - : string + : string|null = NULL
@@ -504,7 +491,7 @@ the connection/database
$pass - : string + : string|null = NULL
@@ -541,9 +528,9 @@ the connection/database

Helper method for quote_ident

@@ -560,7 +547,8 @@ the connection/database : mixed
- +
+
@@ -585,9 +573,9 @@ the connection/database

Returns number of rows affected by an INSERT, UPDATE, DELETE type query

@@ -619,9 +607,9 @@ the connection/database

Method to simplify retrieving db results for meta-data queries

@@ -672,9 +660,9 @@ the connection/database

Retrieve column information for the current database table

@@ -717,9 +705,9 @@ the connection/database

Return list of dbs for the current connection, if possible. Meaningless for SQLite.

@@ -751,9 +739,9 @@ the connection/database

Retrieve foreign keys for the table

@@ -796,9 +784,9 @@ the connection/database

Return list of functions for the current database

@@ -845,9 +833,9 @@ the connection/database

Retrieve indexes for the table

@@ -890,9 +878,9 @@ the connection/database

Get the last sql query executed

@@ -924,9 +912,9 @@ the connection/database

Return list of stored procedures for the current database

@@ -1007,9 +995,9 @@ the connection/database

Return list of sequences for the current database, if they exist

@@ -1041,9 +1029,9 @@ the connection/database

Get the SQL class for the current driver

@@ -1075,9 +1063,9 @@ the connection/database

Retrieves an array of non-user-created tables for @@ -1110,9 +1098,9 @@ the connection/database

List tables for the current database

@@ -1144,9 +1132,9 @@ the connection/database

Return list of triggers for the current database

@@ -1193,9 +1181,9 @@ the connection/database

Retrieve list of data types for the database

@@ -1227,9 +1215,9 @@ the connection/database

Get the Util class for the current driver

@@ -1261,9 +1249,9 @@ the connection/database

Get the version of the database engine

@@ -1295,9 +1283,9 @@ the connection/database

Return list of views for the current database

@@ -1329,16 +1317,16 @@ the connection/database

Create sql for batch insert

public - insertBatch(string $table[, array<string|int, mixed> $data = [] ]) : array<string|int, array<string|int, mixed>>|array<string|int, string>|array<string|int, null> + insertBatch(string $table[, array<string|int, mixed> $data = [] ]) : array<string|int, array<string|int, mixed>>|array<string|int, null>|array<string|int, string>
Parameters
@@ -1362,22 +1350,9 @@ the connection/database

-
- Tags - -
-
-
- codeCoverageIgnore -
-
- - -
-
Return values
- array<string|int, array<string|int, mixed>>|array<string|int, string>|array<string|int, null> + array<string|int, array<string|int, mixed>>|array<string|int, null>|array<string|int, string> — @@ -1395,9 +1370,9 @@ the connection/database

Return the number of rows returned for a SELECT query

@@ -1443,9 +1418,9 @@ the connection/database

Prefixes a table if it is not already prefixed

@@ -1488,9 +1463,9 @@ the connection/database

Create and execute a prepared statement with the provided parameters

@@ -1555,9 +1530,9 @@ the connection/database

Simplifies prepared statements for database queries

@@ -1608,9 +1583,9 @@ the connection/database

Surrounds the string with the databases identifier escape characters

@@ -1653,9 +1628,9 @@ the connection/database

Quote database table name, and set prefix

@@ -1698,9 +1673,9 @@ the connection/database

Generate the returning clause for the current database

@@ -1751,9 +1726,9 @@ the connection/database

Set the last query sql

@@ -1796,9 +1771,9 @@ the connection/database

Set the common table name prefix

@@ -1841,9 +1816,9 @@ the connection/database

Empty the passed table

@@ -1886,9 +1861,9 @@ the connection/database

Creates a batch update, and executes it.

diff --git a/apiDocumentation/classes/Query-Drivers-Sqlite-SQL.html b/apiDocumentation/classes/Query-Drivers-Sqlite-SQL.html index fccbaf0..859b836 100644 --- a/apiDocumentation/classes/Query-Drivers-Sqlite-SQL.html +++ b/apiDocumentation/classes/Query-Drivers-Sqlite-SQL.html @@ -120,9 +120,9 @@

SQLite Specific SQL

@@ -274,9 +274,9 @@ table

SQL to show information about columns in a table

@@ -319,9 +319,9 @@ table

Returns sql to list other databases. Meaningless for SQLite, as this @@ -354,9 +354,9 @@ just returns the database(s) that we are currently connected to.

Get the query plan for the sql query

@@ -399,9 +399,9 @@ just returns the database(s) that we are currently connected to.

Get the list of foreign keys for the current @@ -445,9 +445,9 @@ table

Return sql to list functions

@@ -538,9 +538,9 @@ table

Limit clause

@@ -599,9 +599,9 @@ table

Return sql to list stored procedures

@@ -647,9 +647,9 @@ table

Random ordering keyword

@@ -681,9 +681,9 @@ table

Return sql to list sequences

@@ -715,9 +715,9 @@ table

List the system tables

@@ -749,9 +749,9 @@ table

Returns sql to list tables

@@ -783,9 +783,9 @@ table

Returns sql to list triggers

@@ -817,9 +817,9 @@ table

SQL to show list of field types

@@ -851,9 +851,9 @@ table

Returns sql to list views

diff --git a/apiDocumentation/classes/Query-Drivers-Sqlite-Util.html b/apiDocumentation/classes/Query-Drivers-Sqlite-Util.html index d11406c..6ae2494 100644 --- a/apiDocumentation/classes/Query-Drivers-Sqlite-Util.html +++ b/apiDocumentation/classes/Query-Drivers-Sqlite-Util.html @@ -120,9 +120,9 @@

SQLite-specific backup, import and creation methods

@@ -209,9 +209,9 @@

Save a reference to the connection object for later use

@@ -254,9 +254,9 @@

Create an SQL backup file for the current database's data

@@ -299,9 +299,9 @@

Create an SQL backup file for the current database's structure

@@ -333,9 +333,9 @@

Convenience public function to generate sql for creating a db table

@@ -402,9 +402,9 @@

Drop the selected table

@@ -447,9 +447,9 @@

Get the driver object for the current connection

diff --git a/apiDocumentation/classes/Query-Exception-BadDBDriverException.html b/apiDocumentation/classes/Query-Exception-BadDBDriverException.html index 9014db7..36825b6 100644 --- a/apiDocumentation/classes/Query-Exception-BadDBDriverException.html +++ b/apiDocumentation/classes/Query-Exception-BadDBDriverException.html @@ -119,9 +119,9 @@

Generic exception for bad drivers

diff --git a/apiDocumentation/classes/Query-Exception-NonExistentConnectionException.html b/apiDocumentation/classes/Query-Exception-NonExistentConnectionException.html index 7f99b0b..b00d55e 100644 --- a/apiDocumentation/classes/Query-Exception-NonExistentConnectionException.html +++ b/apiDocumentation/classes/Query-Exception-NonExistentConnectionException.html @@ -119,9 +119,9 @@

Exception for missing database connection

diff --git a/apiDocumentation/classes/Query-Exception-NotImplementedException.html b/apiDocumentation/classes/Query-Exception-NotImplementedException.html index f985182..65081b3 100644 --- a/apiDocumentation/classes/Query-Exception-NotImplementedException.html +++ b/apiDocumentation/classes/Query-Exception-NotImplementedException.html @@ -119,9 +119,9 @@

Exception for non-implemented method

diff --git a/apiDocumentation/classes/Query-JoinType.html b/apiDocumentation/classes/Query-JoinType.html index 6ea9cc9..e207820 100644 --- a/apiDocumentation/classes/Query-JoinType.html +++ b/apiDocumentation/classes/Query-JoinType.html @@ -117,9 +117,9 @@

Enum of join types

@@ -202,56 +202,6 @@ - - - -
- - - - -
-

- INNER - -

- - - - -
- - - -
-
-

- OUTER - -

-
+
+

+ LEFT + +

+ + + + +
+ + + +
+
+

+ RIGHT + +

+ + + + +
+ + +
@@ -334,9 +334,9 @@ diff --git a/apiDocumentation/classes/Query-LikeType.html b/apiDocumentation/classes/Query-LikeType.html index 32e382a..d72474f 100644 --- a/apiDocumentation/classes/Query-LikeType.html +++ b/apiDocumentation/classes/Query-LikeType.html @@ -117,9 +117,9 @@

'Enum' of join types

@@ -188,9 +188,9 @@ @@ -213,9 +213,9 @@ @@ -238,9 +238,9 @@ @@ -270,9 +270,9 @@ diff --git a/apiDocumentation/classes/Query-MapType.html b/apiDocumentation/classes/Query-MapType.html index a98f37e..c613da1 100644 --- a/apiDocumentation/classes/Query-MapType.html +++ b/apiDocumentation/classes/Query-MapType.html @@ -117,9 +117,9 @@

Enum of query map types

@@ -153,56 +153,6 @@ - - - -
- - - - -
-

- GROUP_START - -

- - - - -
- - - -
-
-

- JOIN - -

-
+
+

+ WHERE + +

+ + + + +
+ + + +
+
+

+ WHERE_IN + +

+ + + + +
+ + +
diff --git a/apiDocumentation/classes/Query-QueryBuilder.html b/apiDocumentation/classes/Query-QueryBuilder.html index 870eb9a..ad9b707 100644 --- a/apiDocumentation/classes/Query-QueryBuilder.html +++ b/apiDocumentation/classes/Query-QueryBuilder.html @@ -121,9 +121,9 @@

Convenience class for creating sql queries

@@ -180,14 +180,14 @@  : mixed -
Constructor
+
__destruct()  : mixed
-
Destructor
+
affectedRows() @@ -770,9 +770,9 @@ passed array with key / value pairs

Convenience property for connection management

@@ -805,9 +805,9 @@ passed array with key / value pairs

List of queries executed

@@ -844,9 +844,9 @@ passed array with key / value pairs

Calls a function further down the inheritance chain.

@@ -918,13 +918,13 @@ passed array with key / value pairs -

Constructor

- + public __construct(DriverInterface|null $driver, QueryParser $parser) : mixed - +
+
Parameters
@@ -966,33 +966,20 @@ passed array with key / value pairs -

Destructor

- + public __destruct() : mixed +
+ - -
- Tags - -
-
-
- codeCoverageIgnore -
-
- - -
-
Return values
mixed @@ -1118,9 +1105,9 @@ passed array with key / value pairs

Retrieve the number of rows in the selected table

@@ -1163,9 +1150,9 @@ passed array with key / value pairs

Retrieve the number of results for the generated query - used @@ -1247,7 +1234,8 @@ in place of the get() method

: mixed = ''
- +
+
@@ -1272,9 +1260,9 @@ in place of the get() method

Adds the 'distinct' keyword to a query

@@ -1422,9 +1410,9 @@ in place of the get() method

Tell the database to give you the query plan instead of result set

@@ -1456,9 +1444,9 @@ in place of the get() method

Specify the database table to select from

@@ -1501,9 +1489,9 @@ in place of the get() method

Select and retrieve all records from the current table, and/or @@ -2307,9 +2295,9 @@ execute current compiled query

Convenience method for get() with a where clause

@@ -2375,9 +2363,9 @@ execute current compiled query

Group the results by the selected field(s)

@@ -2394,7 +2382,8 @@ execute current compiled query

: mixed
- +
+
@@ -2419,9 +2408,9 @@ execute current compiled query

Ends a query group

@@ -2453,9 +2442,9 @@ execute current compiled query

Adds a paren to the current query for query grouping

@@ -2487,9 +2476,9 @@ execute current compiled query

Generates a 'Having' clause

@@ -2506,14 +2495,16 @@ execute current compiled query

: mixed
- +
+
$values : mixed = []
- +
+
@@ -2538,9 +2529,9 @@ execute current compiled query

Creates an insert clause, and executes it

@@ -2565,7 +2556,8 @@ execute current compiled query

: mixed = []
- +
+
@@ -2590,9 +2582,9 @@ execute current compiled query

Creates and executes a batch insertion query

@@ -2677,9 +2669,9 @@ execute current compiled query

Creates a join phrase in a compiled query

@@ -2784,9 +2776,9 @@ execute current compiled query

Creates a Like clause in the sql statement

@@ -2811,7 +2803,8 @@ execute current compiled query

: mixed
- +
+
$pos @@ -2844,9 +2837,9 @@ execute current compiled query

Set a limit on the current sql statement

@@ -2897,9 +2890,9 @@ execute current compiled query

Adds a paren to the current query for query grouping, @@ -2932,9 +2925,9 @@ prefixed with 'NOT'

Generates a NOT LIKE clause

@@ -2959,7 +2952,8 @@ prefixed with 'NOT'

: mixed
- +
+
$pos @@ -3027,9 +3021,9 @@ prefixed with 'NOT'

Order the results by the selected field(s)

@@ -3080,9 +3074,9 @@ prefixed with 'NOT'

Adds a paren to the current query for query grouping, @@ -3115,9 +3109,9 @@ prefixed with 'OR'

Generates a 'Having' clause prefixed with 'OR'

@@ -3134,14 +3128,16 @@ prefixed with 'OR'

: mixed
- +
+
$values : mixed = []
- +
+
@@ -3166,9 +3162,9 @@ prefixed with 'OR'

Generates an OR Like clause

@@ -3193,7 +3189,8 @@ prefixed with 'OR'

: mixed
- +
+
$pos @@ -3226,9 +3223,9 @@ prefixed with 'OR'

Adds a paren to the current query for query grouping, @@ -3261,9 +3258,9 @@ prefixed with 'OR NOT'

Generates a OR NOT LIKE clause

@@ -3288,7 +3285,8 @@ prefixed with 'OR NOT'

: mixed
- +
+
$pos @@ -3321,9 +3319,9 @@ prefixed with 'OR NOT'

Where clause prefixed with "OR"

@@ -3347,7 +3345,8 @@ prefixed with 'OR NOT'

: mixed = []
- +
+
@@ -3372,9 +3371,9 @@ prefixed with 'OR NOT'

Where in statement prefixed with "or"

@@ -3391,7 +3390,8 @@ prefixed with 'OR NOT'

: string
- +
+
$val @@ -3424,9 +3424,9 @@ prefixed with 'OR NOT'

OR WHERE NOT IN (FOO) clause

@@ -3443,7 +3443,8 @@ prefixed with 'OR NOT'

: string
- +
+
$val @@ -3738,9 +3739,9 @@ prefixed with 'OR NOT'

Clear out the class variables, so the next query can be run

@@ -3772,9 +3773,9 @@ prefixed with 'OR NOT'

Add a 'returning' clause to an insert,update, or delete query

@@ -3852,9 +3853,9 @@ prefixed with 'OR NOT'

Specifies rows to select in a query

@@ -3897,16 +3898,16 @@ prefixed with 'OR NOT'

Selects the average value of a field from a query

public - selectAvg(string $field[, string|bool $as = FALSE ]) : self + selectAvg(string $field[, bool|string $as = FALSE ]) : self
Parameters
@@ -3921,10 +3922,11 @@ prefixed with 'OR NOT'

$as - : string|bool + : bool|string = FALSE
- +
+
@@ -3958,7 +3960,7 @@ prefixed with 'OR NOT'

public - selectMax(string $field[, string|bool $as = FALSE ]) : self + selectMax(string $field[, bool|string $as = FALSE ]) : self
Parameters
@@ -3973,10 +3975,11 @@ prefixed with 'OR NOT'

$as - : string|bool + : bool|string = FALSE
- +
+
@@ -4001,16 +4004,16 @@ prefixed with 'OR NOT'

Selects the minimum value of a field from a query

public - selectMin(string $field[, string|bool $as = FALSE ]) : self + selectMin(string $field[, bool|string $as = FALSE ]) : self
Parameters
@@ -4025,10 +4028,11 @@ prefixed with 'OR NOT'

$as - : string|bool + : bool|string = FALSE
- +
+
@@ -4053,16 +4057,16 @@ prefixed with 'OR NOT'

Selects the sum of a field from a query

public - selectSum(string $field[, string|bool $as = FALSE ]) : self + selectSum(string $field[, bool|string $as = FALSE ]) : self
Parameters
@@ -4077,10 +4081,11 @@ prefixed with 'OR NOT'

$as - : string|bool + : bool|string = FALSE
- +
+
@@ -4105,9 +4110,9 @@ prefixed with 'OR NOT'

Sets values for inserts / updates / deletes

@@ -4124,7 +4129,8 @@ prefixed with 'OR NOT'

: mixed
- +
+
$val @@ -4257,9 +4263,9 @@ prefixed with 'OR NOT'

Specify the database table to select from

@@ -4278,7 +4284,8 @@ prefixed with 'OR NOT'

: string
- +
+
@@ -4349,9 +4356,9 @@ prefixed with 'OR NOT'

Creates an update clause, and executes it

@@ -4376,7 +4383,8 @@ prefixed with 'OR NOT'

: mixed = []
- +
+
@@ -4401,9 +4409,9 @@ prefixed with 'OR NOT'

Creates a batch update, and executes it.

@@ -4467,9 +4475,9 @@ prefixed with 'OR NOT'

Specify condition(s) in the where clause of a query @@ -4488,14 +4496,16 @@ passed array with key / value pairs

: mixed
- +
+
$values : mixed = []
- +
+
@@ -4520,9 +4530,9 @@ passed array with key / value pairs

Where clause with 'IN' statement

@@ -4539,7 +4549,8 @@ passed array with key / value pairs

: string
- +
+
$val @@ -4572,9 +4583,9 @@ passed array with key / value pairs

WHERE NOT IN (FOO) clause

@@ -4591,7 +4602,8 @@ passed array with key / value pairs

: string
- +
+
$val diff --git a/apiDocumentation/classes/Query-QueryBuilderBase.html b/apiDocumentation/classes/Query-QueryBuilderBase.html index dbdb4b5..42c749e 100644 --- a/apiDocumentation/classes/Query-QueryBuilderBase.html +++ b/apiDocumentation/classes/Query-QueryBuilderBase.html @@ -115,9 +115,9 @@ @@ -161,14 +161,14 @@  : mixed
-
Constructor
+
__destruct()  : mixed
-
Destructor
+
affectedRows() @@ -429,9 +429,9 @@

Convenience property for connection management

@@ -464,9 +464,9 @@

List of queries executed

@@ -503,9 +503,9 @@

Calls a function further down the inheritance chain.

@@ -577,13 +577,13 @@ -

Constructor

- + public __construct(DriverInterface|null $driver, QueryParser $parser) : mixed - +
+
Parameters
@@ -625,33 +625,20 @@ -

Destructor

- + public __destruct() : mixed +
+ - -
- Tags - -
-
-
- codeCoverageIgnore -
-
- - -
-
Return values
mixed @@ -1803,9 +1790,9 @@

Clear out the class variables, so the next query can be run

diff --git a/apiDocumentation/classes/Query-QueryBuilderInterface.html b/apiDocumentation/classes/Query-QueryBuilderInterface.html index 2d1e981..0cd11f0 100644 --- a/apiDocumentation/classes/Query-QueryBuilderInterface.html +++ b/apiDocumentation/classes/Query-QueryBuilderInterface.html @@ -111,9 +111,9 @@

Interface defining the Query Builder class

@@ -478,9 +478,9 @@ passed array with key / value pairs

Retrieve the number of rows in the selected table

@@ -523,9 +523,9 @@ passed array with key / value pairs

Retrieve the number of results for the generated query - used @@ -580,9 +580,9 @@ in place of the get() method

Deletes data from a table

@@ -607,7 +607,8 @@ in place of the get() method

: mixed = ''
- +
+
@@ -632,9 +633,9 @@ in place of the get() method

Adds the 'distinct' keyword to a query

@@ -666,9 +667,9 @@ in place of the get() method

Shows the query plan for the query

@@ -700,9 +701,9 @@ in place of the get() method

Specify the database table to select from

@@ -745,9 +746,9 @@ in place of the get() method

Select and retrieve all records from the current table, and/or @@ -807,9 +808,9 @@ execute current compiled query

Returns the generated 'delete' sql query

@@ -860,9 +861,9 @@ execute current compiled query

Returns the generated 'insert' sql query

@@ -913,9 +914,9 @@ execute current compiled query

Returns the generated 'select' sql query

@@ -966,9 +967,9 @@ execute current compiled query

Returns the generated 'update' sql query

@@ -1019,9 +1020,9 @@ execute current compiled query

Convenience method for get() with a where clause

@@ -1046,7 +1047,8 @@ execute current compiled query

: array<string|int, mixed> = []
- +
+
$limit @@ -1087,9 +1089,9 @@ execute current compiled query

Group the results by the selected field(s)

@@ -1106,7 +1108,8 @@ execute current compiled query

: mixed
- +
+
@@ -1131,9 +1134,9 @@ execute current compiled query

Ends a query group

@@ -1165,9 +1168,9 @@ execute current compiled query

Adds a paren to the current query for query grouping

@@ -1199,9 +1202,9 @@ execute current compiled query

Generates a 'Having' clause

@@ -1218,14 +1221,16 @@ execute current compiled query

: mixed
- +
+
$values : mixed = []
- +
+
@@ -1250,9 +1255,9 @@ execute current compiled query

Creates an insert clause, and executes it

@@ -1277,7 +1282,8 @@ execute current compiled query

: mixed = []
- +
+
@@ -1302,9 +1308,9 @@ execute current compiled query

Creates and executes a batch insertion query

@@ -1354,9 +1360,9 @@ execute current compiled query

Creates a join phrase in a compiled query

@@ -1415,9 +1421,9 @@ execute current compiled query

Creates a Like clause in the sql statement

@@ -1442,7 +1448,8 @@ execute current compiled query

: mixed
- +
+
$pos @@ -1475,9 +1482,9 @@ execute current compiled query

Set a limit on the current sql statement

@@ -1528,9 +1535,9 @@ execute current compiled query

Adds a paren to the current query for query grouping, @@ -1563,9 +1570,9 @@ prefixed with 'NOT'

Generates a NOT LIKE clause

@@ -1590,7 +1597,8 @@ prefixed with 'NOT'

: mixed
- +
+
$pos @@ -1623,9 +1631,9 @@ prefixed with 'NOT'

Order the results by the selected field(s)

@@ -1676,9 +1684,9 @@ prefixed with 'NOT'

Adds a paren to the current query for query grouping, @@ -1711,9 +1719,9 @@ prefixed with 'OR'

Generates a 'Having' clause prefixed with 'OR'

@@ -1730,14 +1738,16 @@ prefixed with 'OR'

: mixed
- +
+
$values : mixed = []
- +
+
@@ -1762,9 +1772,9 @@ prefixed with 'OR'

Generates an OR Like clause

@@ -1789,7 +1799,8 @@ prefixed with 'OR'

: mixed
- +
+
$pos @@ -1822,9 +1833,9 @@ prefixed with 'OR'

Adds a paren to the current query for query grouping, @@ -1857,9 +1868,9 @@ prefixed with 'OR NOT'

Generates a OR NOT LIKE clause

@@ -1884,7 +1895,8 @@ prefixed with 'OR NOT'

: mixed
- +
+
$pos @@ -1917,9 +1929,9 @@ prefixed with 'OR NOT'

Where clause prefixed with "OR"

@@ -1943,7 +1955,8 @@ prefixed with 'OR NOT'

: mixed = []
- +
+
@@ -1968,9 +1981,9 @@ prefixed with 'OR NOT'

Where in statement prefixed with "or"

@@ -1987,14 +2000,16 @@ prefixed with 'OR NOT'

: string
- +
+
$values : mixed = []
- +
+
@@ -2019,9 +2034,9 @@ prefixed with 'OR NOT'

OR WHERE NOT IN (FOO) clause

@@ -2038,14 +2053,16 @@ prefixed with 'OR NOT'

: string
- +
+
$values : mixed = []
- +
+
@@ -2070,9 +2087,9 @@ prefixed with 'OR NOT'

Clear out the class variables, so the next query can be run

@@ -2104,9 +2121,9 @@ prefixed with 'OR NOT'

Specifies rows to select in a query

@@ -2149,16 +2166,16 @@ prefixed with 'OR NOT'

Selects the average value of a field from a query

public - selectAvg(string $field[, string|bool $as = FALSE ]) : self + selectAvg(string $field[, bool|string $as = FALSE ]) : self
Parameters
@@ -2173,10 +2190,11 @@ prefixed with 'OR NOT'

$as - : string|bool + : bool|string = FALSE
- +
+
@@ -2201,16 +2219,16 @@ prefixed with 'OR NOT'

Selects the maximum value of a field from a query

public - selectMax(string $field[, string|bool $as = FALSE ]) : self + selectMax(string $field[, bool|string $as = FALSE ]) : self
Parameters
@@ -2225,10 +2243,11 @@ prefixed with 'OR NOT'

$as - : string|bool + : bool|string = FALSE
- +
+
@@ -2253,16 +2272,16 @@ prefixed with 'OR NOT'

Selects the minimum value of a field from a query

public - selectMin(string $field[, string|bool $as = FALSE ]) : self + selectMin(string $field[, bool|string $as = FALSE ]) : self
Parameters
@@ -2277,10 +2296,11 @@ prefixed with 'OR NOT'

$as - : string|bool + : bool|string = FALSE
- +
+
@@ -2305,16 +2325,16 @@ prefixed with 'OR NOT'

Selects the sum of a field from a query

public - selectSum(string $field[, string|bool $as = FALSE ]) : self + selectSum(string $field[, bool|string $as = FALSE ]) : self
Parameters
@@ -2329,10 +2349,11 @@ prefixed with 'OR NOT'

$as - : string|bool + : bool|string = FALSE
- +
+
@@ -2357,9 +2378,9 @@ prefixed with 'OR NOT'

Sets values for inserts / updates / deletes

@@ -2376,14 +2397,16 @@ prefixed with 'OR NOT'

: mixed
- +
+
$values : mixed = NULL
- +
+
@@ -2408,9 +2431,9 @@ prefixed with 'OR NOT'

Specify the database table to select from

@@ -2429,7 +2452,8 @@ prefixed with 'OR NOT'

: string
- +
+
@@ -2454,9 +2478,9 @@ prefixed with 'OR NOT'

Creates an update clause, and executes it

@@ -2481,7 +2505,8 @@ prefixed with 'OR NOT'

: mixed = []
- +
+
@@ -2506,9 +2531,9 @@ prefixed with 'OR NOT'

Creates a batch update, and executes it.

@@ -2572,9 +2597,9 @@ prefixed with 'OR NOT'

Specify condition(s) in the where clause of a query @@ -2593,14 +2618,16 @@ passed array with key / value pairs

: mixed
- +
+
$values : mixed = []
- +
+
@@ -2625,9 +2652,9 @@ passed array with key / value pairs

Where clause with 'IN' statement

@@ -2644,14 +2671,16 @@ passed array with key / value pairs

: string
- +
+
$values : mixed = []
- +
+
@@ -2676,9 +2705,9 @@ passed array with key / value pairs

WHERE NOT IN (FOO) clause

@@ -2695,14 +2724,16 @@ passed array with key / value pairs

: string
- +
+
$values : mixed = []
- +
+
diff --git a/apiDocumentation/classes/Query-QueryParser.html b/apiDocumentation/classes/Query-QueryParser.html index 93613ec..faed22b 100644 --- a/apiDocumentation/classes/Query-QueryParser.html +++ b/apiDocumentation/classes/Query-QueryParser.html @@ -115,9 +115,9 @@

Utility Class to parse sql clauses for properly escaping identifiers

@@ -192,9 +192,9 @@

Regex matches

@@ -231,9 +231,9 @@

Constructor/entry point into parser

@@ -276,9 +276,9 @@

Compiles a join condition after parsing

@@ -321,9 +321,9 @@

Parser method for setting the parse string

diff --git a/apiDocumentation/classes/Query-QueryType.html b/apiDocumentation/classes/Query-QueryType.html index 6cf7bd9..c61a9a2 100644 --- a/apiDocumentation/classes/Query-QueryType.html +++ b/apiDocumentation/classes/Query-QueryType.html @@ -117,9 +117,9 @@

Enum of query types

@@ -153,56 +153,6 @@ - - - -
- - - - -
-

- INSERT - -

- - - - -
- - - -
-
-

- INSERT_BATCH - -

-
+
+

+ UPDATE_BATCH + +

+ + + + +
+ + + +
+
+

+ DELETE + +

+ + + + +
+ + +
diff --git a/apiDocumentation/classes/Query-State.html b/apiDocumentation/classes/Query-State.html index e6d9175..c316459 100644 --- a/apiDocumentation/classes/Query-State.html +++ b/apiDocumentation/classes/Query-State.html @@ -115,9 +115,9 @@

Query builder state

@@ -386,9 +386,9 @@ @@ -439,9 +439,9 @@ @@ -484,9 +484,9 @@ @@ -529,9 +529,9 @@

Add an additional set of mapping pairs to a internal map

@@ -590,9 +590,9 @@ @@ -635,9 +635,9 @@ @@ -680,9 +680,9 @@ @@ -725,9 +725,9 @@ @@ -1488,9 +1488,9 @@ diff --git a/apiDocumentation/files/src-common.html b/apiDocumentation/files/src-common.html index 11f3e4b..d4ad677 100644 --- a/apiDocumentation/files/src-common.html +++ b/apiDocumentation/files/src-common.html @@ -221,9 +221,9 @@ passed

Multibyte-safe trim function

@@ -261,9 +261,9 @@ passed

Filter out db rows into one array

@@ -309,9 +309,9 @@ passed

Zip a set of arrays together on common keys

@@ -352,9 +352,9 @@ array.

Determine whether a value in the passed array matches the pattern @@ -401,9 +401,9 @@ passed

Connection function

diff --git a/apiDocumentation/files/src/ConnectionManager.php.txt b/apiDocumentation/files/src/ConnectionManager.php.txt index 6b6ffac..f538d5d 100644 --- a/apiDocumentation/files/src/ConnectionManager.php.txt +++ b/apiDocumentation/files/src/ConnectionManager.php.txt @@ -13,17 +13,20 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query; use DomainException; +use PHPUnit\Framework\Attributes\CodeCoverageIgnore; +use Query\Exception\{BadDBDriverException, NonExistentConnectionException}; use stdClass; /** * Connection manager class to manage connections for the * Query method */ -final class ConnectionManager { - +final class ConnectionManager +{ /** * Map of named database connections */ @@ -36,8 +39,8 @@ final class ConnectionManager { /** * Private constructor to prevent multiple instances - * @codeCoverageIgnore */ + #[CodeCoverageIgnore] private function __construct() { } @@ -91,7 +94,6 @@ final class ConnectionManager { /** * Returns the connection specified by the name given * - * @param string $name * @throws Exception\NonExistentConnectionException */ public function getConnection(string $name = ''): QueryBuilderInterface @@ -108,20 +110,17 @@ final class ConnectionManager { } // You should actually connect before trying to get a connection... - throw new Exception\NonExistentConnectionException('The specified connection does not exist'); + throw new NonExistentConnectionException('The specified connection does not exist'); } /** * Parse the passed parameters and return a connection - * - * @param array|object $params - * @return QueryBuilderInterface */ public function connect(array|object $params): QueryBuilderInterface { [$dsn, $dbType, $params, $options] = $this->parseParams($params); - $dbType = ucfirst($dbType); + $dbType = ucfirst((string) $dbType); $driver = "\\Query\\Drivers\\{$dbType}\\Driver"; // Create the database connection @@ -138,7 +137,6 @@ final class ConnectionManager { // Create Query Builder object $conn = new QueryBuilder($db, new QueryParser($db)); - // Save it for later if (isset($params->alias)) { @@ -155,21 +153,19 @@ final class ConnectionManager { /** * Parses params into a dsn and option array * - * @param array|object $rawParams * @throws Exception\BadDBDriverException - * @return array */ public function parseParams(array|object $rawParams): array { $params = (object) $rawParams; - $params->type = strtolower($params->type); + $params->type = strtolower((string) $params->type); $dbType = ($params->type === 'postgresql') ? 'pgsql' : $params->type; $dbType = ucfirst($dbType); // Make sure the class exists if ( ! class_exists("\\Query\\Drivers\\{$dbType}\\Driver")) { - throw new Exception\BadDBDriverException('Database driver does not exist, or is not supported'); + throw new BadDBDriverException('Database driver does not exist, or is not supported'); } // Set additional PDO options @@ -183,15 +179,13 @@ final class ConnectionManager { // Create the dsn for the database to connect to $dsn = strtolower($dbType) === 'sqlite' ? $params->file : $this->createDsn($dbType, $params); - return [$dsn, $dbType, $params, $options]; } /** * Create the dsn from the db type and params - * - * @codeCoverageIgnore */ + #[CodeCoverageIgnore] private function createDsn(string $dbType, stdClass $params): string { $pairs = []; @@ -209,12 +203,12 @@ final class ConnectionManager { 'prefix' => 'prefix', 'options' => 'options', 'database' => 'database', - 'alias' => 'alias' + 'alias' => 'alias', ]; - foreach($params as $key => $val) + foreach ($params as $key => $val) { - if (( ! array_key_exists($key, $skip)) && ! empty($val)) + if (( ! array_key_exists($key, $skip)) && ! empty($val)) { $pairs[] = implode('=', [$key, $val]); } @@ -222,4 +216,4 @@ final class ConnectionManager { return strtolower($dbType) . ':' . implode(';', $pairs); } -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/Drivers/AbstractDriver.php.txt b/apiDocumentation/files/src/Drivers/AbstractDriver.php.txt index e4274ef..e1e5986 100644 --- a/apiDocumentation/files/src/Drivers/AbstractDriver.php.txt +++ b/apiDocumentation/files/src/Drivers/AbstractDriver.php.txt @@ -13,11 +13,13 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query\Drivers; use InvalidArgumentException; use PDO; use PDOStatement; +use PHPUnit\Framework\Attributes\CodeCoverageIgnore; use function call_user_func_array; use function dbFilter; @@ -29,10 +31,8 @@ use function is_string; * * Extends PDO to simplify cross-database issues */ -abstract class AbstractDriver - extends PDO - implements DriverInterface { - +abstract class AbstractDriver extends PDO implements DriverInterface +{ /** * Reference to the last executed query */ @@ -76,7 +76,7 @@ abstract class AbstractDriver /** * PDO constructor wrapper */ - public function __construct(string $dsn, string $username=NULL, string $password=NULL, array $driverOptions=[]) + public function __construct(string $dsn, ?string $username=NULL, ?string $password=NULL, array $driverOptions=[]) { // Set PDO to display errors as exceptions, and apply driver options $driverOptions[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; @@ -85,14 +85,33 @@ abstract class AbstractDriver $this->_loadSubClasses(); } + /** + * Allow invoke to work on table object + * + * @return mixed + */ + #[CodeCoverageIgnore] + public function __call(string $name, array $args = []) + { + if ( + isset($this->$name) + && is_object($this->$name) + && method_exists($this->$name, '__invoke') + ) { + return call_user_func_array([$this->$name, '__invoke'], $args); + } + + return NULL; + } + /** * Loads the subclasses for the driver */ protected function _loadSubClasses(): void { // Load the sql and util class for the driver - $thisClass = $this::class; - $nsArray = explode("\\", $thisClass); + $thisClass = static::class; + $nsArray = explode('\\', $thisClass); array_pop($nsArray); $driver = array_pop($nsArray); $sqlClass = __NAMESPACE__ . "\\{$driver}\\SQL"; @@ -102,26 +121,6 @@ abstract class AbstractDriver $this->util = new $utilClass($this); } - /** - * Allow invoke to work on table object - * - * @codeCoverageIgnore - * @return mixed - */ - public function __call(string $name, array $args = []) - { - if ( - isset($this->$name) - && is_object($this->$name) - && method_exists($this->$name, '__invoke') - ) - { - return call_user_func_array([$this->$name, '__invoke'], $args); - } - - return NULL; - } - // -------------------------------------------------------------------------- // ! Accessors / Mutators // -------------------------------------------------------------------------- @@ -177,11 +176,11 @@ abstract class AbstractDriver $this->statement = $this->prepare($sql); // Bind the parameters - foreach($data as $k => $value) + foreach ($data as $k => $value) { // Parameters are 1-based, the data is 0-based // So, if the key is numeric, add 1 - if(is_numeric($k)) + if (is_numeric($k)) { $k++; } @@ -258,7 +257,7 @@ abstract class AbstractDriver { if (is_array($identifier)) { - return array_map([$this, __METHOD__], $identifier); + return array_map(__METHOD__, $identifier); } // Make all the string-handling methods happy @@ -268,7 +267,7 @@ abstract class AbstractDriver if (str_contains($identifier, ',')) { $parts = array_map('mb_trim', explode(',', $identifier)); - $parts = array_map([$this, __METHOD__], $parts); + $parts = array_map(__METHOD__, $parts); $identifier = implode(',', $parts); } @@ -277,12 +276,13 @@ abstract class AbstractDriver $hiers = array_map('mb_trim', $hiers); // Re-compile the string - $raw = implode('.', array_map([$this, '_quote'], $hiers)); + $raw = implode('.', array_map($this->_quote(...), $hiers)); // Fix functions $funcs = []; preg_match_all("#{$this->escapeCharOpen}([a-zA-Z0-9_]+(\((.*?)\))){$this->escapeCharClose}#iu", $raw, $funcs, PREG_SET_ORDER); - foreach($funcs as $f) + + foreach ($funcs as $f) { // Unquote the function // Quote the inside identifiers @@ -308,6 +308,7 @@ abstract class AbstractDriver { $tables = $this->driverQuery('tableList'); natsort($tables); + return $tables; } @@ -326,6 +327,7 @@ abstract class AbstractDriver { $views = $this->driverQuery('viewList'); sort($views); + return $views; } @@ -456,6 +458,7 @@ abstract class AbstractDriver if (preg_match($regex, $this->lastQuery, $output) > 0) { $stmt = $this->query("SELECT COUNT(*) FROM {$output[1]}"); + return (int) $stmt->fetchColumn(); } @@ -472,7 +475,8 @@ abstract class AbstractDriver // Values for insertion $vals = []; - foreach($data as $group) + + foreach ($data as $group) { $vals = [...$vals, ...array_values($group)]; } @@ -533,6 +537,7 @@ abstract class AbstractDriver $line = $this->quoteIdent($field) . " = CASE\n"; $cases = []; + foreach ($data as $case) { if (array_key_exists($field, $case)) @@ -553,6 +558,7 @@ abstract class AbstractDriver $sql .= implode(",\n", $fieldLines) . "\n"; $whereValues = array_column($data, $where); + foreach ($whereValues as $value) { $insertData[] = $value; @@ -579,6 +585,7 @@ abstract class AbstractDriver $sql .= $this->quoteTable($table); $this->statement = $this->query($sql); + return $this->statement; } @@ -592,9 +599,6 @@ abstract class AbstractDriver /** * Helper method for quote_ident - * - * @param mixed $str - * @return mixed */ public function _quote(mixed $str): mixed { @@ -608,7 +612,6 @@ abstract class AbstractDriver ) ? "{$this->escapeCharOpen}{$str}{$this->escapeCharClose}" : $str; - } /** diff --git a/apiDocumentation/files/src/Drivers/AbstractSQL.php.txt b/apiDocumentation/files/src/Drivers/AbstractSQL.php.txt index 3dcfd89..aeefa8d 100644 --- a/apiDocumentation/files/src/Drivers/AbstractSQL.php.txt +++ b/apiDocumentation/files/src/Drivers/AbstractSQL.php.txt @@ -13,13 +13,14 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query\Drivers; /** * Parent for database-specific syntax subclasses */ -abstract class AbstractSQL implements SQLInterface { - +abstract class AbstractSQL implements SQLInterface +{ /** * Limit clause */ diff --git a/apiDocumentation/files/src/Drivers/AbstractUtil.php.txt b/apiDocumentation/files/src/Drivers/AbstractUtil.php.txt index b3bc5ea..fc5034b 100644 --- a/apiDocumentation/files/src/Drivers/AbstractUtil.php.txt +++ b/apiDocumentation/files/src/Drivers/AbstractUtil.php.txt @@ -13,13 +13,16 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query\Drivers; +use function arrayZipper; + /** * Abstract class defining database / table creation methods */ -abstract class AbstractUtil { - +abstract class AbstractUtil +{ /** * Save a reference to the connection object for later use */ @@ -48,14 +51,15 @@ abstract class AbstractUtil { // 'constraint' => ..., // 'index' => ..., // ] - $columnArray = \arrayZipper([ + $columnArray = arrayZipper([ 'type' => $fields, - 'constraint' => $constraints + 'constraint' => $constraints, ]); // Join column definitions together $columns = []; - foreach($columnArray as $n => $props) + + foreach ($columnArray as $n => $props) { $str = $this->getDriver()->quoteIdent($n); $str .= isset($props['type']) ? " {$props['type']}" : ''; @@ -65,7 +69,7 @@ abstract class AbstractUtil { } // Generate the sql for the creation of the table - $sql = 'CREATE TABLE'.$existsStr.$this->getDriver()->quoteTable($name).' ('; + $sql = 'CREATE TABLE' . $existsStr . $this->getDriver()->quoteTable($name) . ' ('; $sql .= implode(', ', $columns); $sql .= ')'; @@ -77,7 +81,7 @@ abstract class AbstractUtil { */ public function deleteTable(string $name): string { - return 'DROP TABLE IF EXISTS '.$this->getDriver()->quoteTable($name); + return 'DROP TABLE IF EXISTS ' . $this->getDriver()->quoteTable($name); } // -------------------------------------------------------------------------- @@ -85,16 +89,11 @@ abstract class AbstractUtil { // -------------------------------------------------------------------------- /** * Return an SQL file with the database table structure - * - * @abstract */ abstract public function backupStructure(): string; /** * Return an SQL file with the database data as insert statements - * - * @abstract */ abstract public function backupData(): string; - -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/Drivers/DriverInterface.php.txt b/apiDocumentation/files/src/Drivers/DriverInterface.php.txt index d3073fd..baaa142 100644 --- a/apiDocumentation/files/src/Drivers/DriverInterface.php.txt +++ b/apiDocumentation/files/src/Drivers/DriverInterface.php.txt @@ -13,9 +13,9 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query\Drivers; -use InvalidArgumentException; use PDO; use PDOStatement; @@ -36,12 +36,12 @@ use PDOStatement; * @method rollback(): bool * @method setAttribute(int $attribute, $value): bool */ -interface DriverInterface /* extends the interface of PDO */ { - +interface DriverInterface // extends the interface of PDO +{ /** * Constructor/Connection method */ - public function __construct(string $dsn, string $username=NULL, string $password=NULL, array $driverOptions = []); + public function __construct(string $dsn, ?string $username=NULL, ?string $password=NULL, array $driverOptions = []); /** * Simplifies prepared statements for database queries diff --git a/apiDocumentation/files/src/Drivers/Mysql/Driver.php.txt b/apiDocumentation/files/src/Drivers/Mysql/Driver.php.txt index c03fc32..f4e6936 100644 --- a/apiDocumentation/files/src/Drivers/Mysql/Driver.php.txt +++ b/apiDocumentation/files/src/Drivers/Mysql/Driver.php.txt @@ -13,17 +13,19 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query\Drivers\Mysql; use PDO; +use PHPUnit\Framework\Attributes\CodeCoverageIgnore; use Query\Drivers\AbstractDriver; use function defined; /** * MySQL specific class */ -class Driver extends AbstractDriver { - +class Driver extends AbstractDriver +{ /** * Set the backtick as the MySQL escape character */ @@ -36,10 +38,9 @@ class Driver extends AbstractDriver { /** * Connect to MySQL Database - * - * @codeCoverageIgnore */ - public function __construct(string $dsn, string $username=NULL, string $password=NULL, array $options=[]) + #[CodeCoverageIgnore] + public function __construct(string $dsn, ?string $username=NULL, ?string $password=NULL, array $options=[]) { // Set the charset to UTF-8 if (defined('\\PDO::MYSQL_ATTR_INIT_COMMAND')) @@ -51,7 +52,7 @@ class Driver extends AbstractDriver { if ( ! str_contains($dsn, 'mysql')) { - $dsn = 'mysql:'.$dsn; + $dsn = 'mysql:' . $dsn; } parent::__construct($dsn, $username, $password, $options); @@ -67,7 +68,7 @@ class Driver extends AbstractDriver { if ( stripos($query, 'insert') !== FALSE && version_compare($this->getVersion(), '10.5.0', '>=') - ){ + ) { return parent::returning($query, $select); } @@ -75,11 +76,11 @@ class Driver extends AbstractDriver { if ( stripos($query, 'delete') !== FALSE && version_compare($this->getVersion(), '10.0.5', '>=') - ){ + ) { return parent::returning($query, $select); } // Just return the same SQL if the returning clause is not supported return $query; } -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/Drivers/Mysql/SQL.php.txt b/apiDocumentation/files/src/Drivers/Mysql/SQL.php.txt index e0e8a59..e4da5fb 100644 --- a/apiDocumentation/files/src/Drivers/Mysql/SQL.php.txt +++ b/apiDocumentation/files/src/Drivers/Mysql/SQL.php.txt @@ -13,15 +13,17 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query\Drivers\Mysql; +use PHPUnit\Framework\Attributes\CodeCoverageIgnore; use Query\Drivers\AbstractSQL; /** * MySQL specific SQL */ -class SQL extends AbstractSQL { - +class SQL extends AbstractSQL +{ /** * Limit clause */ @@ -29,10 +31,10 @@ class SQL extends AbstractSQL { { if ( ! is_numeric($offset)) { - return $sql." LIMIT {$limit}"; + return $sql . " LIMIT {$limit}"; } - return $sql." LIMIT {$offset}, {$limit}"; + return $sql . " LIMIT {$offset}, {$limit}"; } /** @@ -56,10 +58,9 @@ class SQL extends AbstractSQL { */ public function dbList(): string { - return <<getDriver(); $dbs = $driver->getDbs(); - foreach($dbs as &$d) + foreach ($dbs as &$d) { // Skip built-in dbs // @codeCoverageIgnoreStart @@ -47,7 +48,7 @@ class Util extends AbstractUtil { // Get the list of tables $tables = $driver->driverQuery("SHOW TABLES FROM `{$d}`", TRUE); - foreach($tables as $table) + foreach ($tables as $table) { $array = $driver->driverQuery("SHOW CREATE TABLE `{$d}`.`{$table}`", FALSE); $row = current($array); @@ -57,7 +58,6 @@ class Util extends AbstractUtil { continue; } - $string[] = $row['Create Table']; } } @@ -74,7 +74,7 @@ class Util extends AbstractUtil { $tables = $driver->getTables(); // Filter out the tables you don't want - if( ! empty($exclude)) + if ( ! empty($exclude)) { $tables = array_diff($tables, $exclude); } @@ -82,7 +82,7 @@ class Util extends AbstractUtil { $outputSql = ''; // Select the rows from each Table - foreach($tables as $t) + foreach ($tables as $t) { $sql = "SELECT * FROM `{$t}`"; $res = $driver->query($sql); @@ -100,24 +100,24 @@ class Util extends AbstractUtil { $insertRows = []; // Create the insert statements - foreach($rows as $row) + foreach ($rows as $row) { $row = array_values($row); // Quote strings - $row = array_map(fn ($r) => is_string($r) ? $driver->quote($r) : $r, $row); + $row = array_map(static fn ($r) => is_string($r) ? $driver->quote($r) : $r, $row); $row = array_map('trim', $row); - $rowString = 'INSERT INTO `'.trim($t).'` (`'.implode('`,`', $columns).'`) VALUES ('.implode(',', $row).');'; + $rowString = 'INSERT INTO `' . trim((string) $t) . '` (`' . implode('`,`', $columns) . '`) VALUES (' . implode(',', $row) . ');'; $row = NULL; $insertRows[] = $rowString; } - $outputSql .= "\n\n".implode("\n", $insertRows)."\n"; + $outputSql .= "\n\n" . implode("\n", $insertRows) . "\n"; } return $outputSql; } -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/Drivers/Pgsql/Driver.php.txt b/apiDocumentation/files/src/Drivers/Pgsql/Driver.php.txt index 86e6e60..d9d8368 100644 --- a/apiDocumentation/files/src/Drivers/Pgsql/Driver.php.txt +++ b/apiDocumentation/files/src/Drivers/Pgsql/Driver.php.txt @@ -13,25 +13,26 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query\Drivers\Pgsql; +use PHPUnit\Framework\Attributes\CodeCoverageIgnore; use Query\Drivers\AbstractDriver; /** * PostgreSQL specific class */ -class Driver extends AbstractDriver { - +class Driver extends AbstractDriver +{ /** * Connect to a PosgreSQL database - * - * @codeCoverageIgnore */ - public function __construct(string $dsn, string $username=NULL, string $password=NULL, array $options=[]) + #[CodeCoverageIgnore] + public function __construct(string $dsn, ?string $username=NULL, ?string $password=NULL, array $options=[]) { if ( ! str_contains($dsn, 'pgsql')) { - $dsn = 'pgsql:'.$dsn; + $dsn = 'pgsql:' . $dsn; } parent::__construct($dsn, $username, $password, $options); @@ -63,9 +64,9 @@ SQL; $keys = parent::getFks($table); - foreach($keys as &$key) + foreach ($keys as &$key) { - foreach(['update', 'delete'] AS $type) + foreach (['update', 'delete'] as $type) { if ( ! isset($valueMap[$key[$type]])) { @@ -80,4 +81,4 @@ SQL; return $keys; } -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/Drivers/Pgsql/SQL.php.txt b/apiDocumentation/files/src/Drivers/Pgsql/SQL.php.txt index 4fb34aa..773ef32 100644 --- a/apiDocumentation/files/src/Drivers/Pgsql/SQL.php.txt +++ b/apiDocumentation/files/src/Drivers/Pgsql/SQL.php.txt @@ -13,6 +13,7 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query\Drivers\Pgsql; use Query\Drivers\AbstractSQL; @@ -20,8 +21,8 @@ use Query\Drivers\AbstractSQL; /** * PostgreSQL specific SQL */ -class SQL extends AbstractSQL { - +class SQL extends AbstractSQL +{ /** * Get the query plan for the sql query */ @@ -43,7 +44,7 @@ class SQL extends AbstractSQL { */ public function dbList(): string { - return <<getDriver()->getTables(); // Filter out the tables you don't want - if( ! empty($exclude)) + if ( ! empty($exclude)) { $tables = array_diff($tables, $exclude); } @@ -48,9 +49,9 @@ class Util extends AbstractUtil { $outputSql = ''; // Get the data for each object - foreach($tables as $t) + foreach ($tables as $t) { - $sql = 'SELECT * FROM "'.trim($t).'"'; + $sql = 'SELECT * FROM "' . trim((string) $t) . '"'; $res = $this->getDriver()->query($sql); $objRes = $res->fetchAll(PDO::FETCH_ASSOC); @@ -68,7 +69,7 @@ class Util extends AbstractUtil { $insertRows = []; // Create the insert statements - foreach($objRes as $row) + foreach ($objRes as $row) { $row = array_values($row); @@ -76,8 +77,7 @@ class Util extends AbstractUtil { $row = array_map([$this->getDriver(), 'quote'], $row); $row = array_map('trim', $row); - - $rowString = 'INSERT INTO "'.trim($t).'" ("'.implode('","', $columns).'") VALUES ('.implode(',', $row).');'; + $rowString = 'INSERT INTO "' . trim((string) $t) . '" ("' . implode('","', $columns) . '") VALUES (' . implode(',', $row) . ');'; $row = NULL; @@ -86,9 +86,9 @@ class Util extends AbstractUtil { $objRes = NULL; - $outputSql .= "\n\n".implode("\n", $insertRows)."\n"; + $outputSql .= "\n\n" . implode("\n", $insertRows) . "\n"; } return $outputSql; } -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/Drivers/SQLInterface.php.txt b/apiDocumentation/files/src/Drivers/SQLInterface.php.txt index 048d463..a9f0531 100644 --- a/apiDocumentation/files/src/Drivers/SQLInterface.php.txt +++ b/apiDocumentation/files/src/Drivers/SQLInterface.php.txt @@ -13,13 +13,14 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query\Drivers; /** * Interface for database-specific syntax subclasses */ -interface SQLInterface { - +interface SQLInterface +{ /** * Get database specific sql for limit clause */ @@ -96,4 +97,4 @@ interface SQLInterface { * Get the list of indexes for the current table */ public function indexList(string $table): string; -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/Drivers/Sqlite/Driver.php.txt b/apiDocumentation/files/src/Drivers/Sqlite/Driver.php.txt index 44e7d59..b909841 100644 --- a/apiDocumentation/files/src/Drivers/Sqlite/Driver.php.txt +++ b/apiDocumentation/files/src/Drivers/Sqlite/Driver.php.txt @@ -13,18 +13,21 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ -namespace Query\Drivers\Sqlite; -use function is_array; +namespace Query\Drivers\Sqlite; use InvalidArgumentException; use PDO; + +use PHPUnit\Framework\Attributes\CodeCoverageIgnore; use Query\Drivers\AbstractDriver; +use function is_array; /** * SQLite specific class */ -class Driver extends AbstractDriver { +class Driver extends AbstractDriver +{ /** * SQLite has a truncate optimization, * but no support for the actual keyword @@ -34,7 +37,7 @@ class Driver extends AbstractDriver { /** * Open SQLite Database */ - public function __construct(string $dsn, string $user=NULL, string $pass=NULL, array $driverOptions=[]) + public function __construct(string $dsn, ?string $user=NULL, ?string $pass=NULL, array $driverOptions=[]) { if ( ! str_contains($dsn, 'sqlite:')) { @@ -59,6 +62,7 @@ class Driver extends AbstractDriver { { $sql = $this->getSql()->tableList(); $res = $this->query($sql); + return dbFilter($res->fetchAll(PDO::FETCH_ASSOC), 'name'); } @@ -69,14 +73,14 @@ class Driver extends AbstractDriver { { $returnRows = []; - foreach(parent::getFks($table) as $row) + foreach (parent::getFks($table) as $row) { $returnRows[] = [ 'child_column' => $row['from'], 'parent_table' => $row['table'], 'parent_column' => $row['to'], 'update' => $row['on_update'], - 'delete' => $row['on_delete'] + 'delete' => $row['on_delete'], ]; } @@ -86,9 +90,9 @@ class Driver extends AbstractDriver { /** * Create sql for batch insert * - * @codeCoverageIgnore - * @return array[]|string[]|null[] + * @return array[]|null[]|string[] */ + #[CodeCoverageIgnore] public function insertBatch(string $table, array $data=[]): array { // If greater than version 3.7.11, supports the same syntax as @@ -115,13 +119,14 @@ class Driver extends AbstractDriver { // Create a key-value mapping for each field $first = array_shift($data); $cols = []; - foreach($first as $colName => $datum) + + foreach ($first as $colName => $datum) { $cols[] = $this->_quote($datum) . ' AS ' . $this->quoteIdent($colName); } $sql .= 'SELECT ' . implode(', ', $cols) . "\n"; - foreach($data as $union) + foreach ($data as $union) { $vals = array_map([$this, 'quote'], $union); $sql .= 'UNION SELECT ' . implode(',', $vals) . "\n"; @@ -138,4 +143,4 @@ class Driver extends AbstractDriver { // Return the same query, as the returning clause is not supported return $query; } -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/Drivers/Sqlite/SQL.php.txt b/apiDocumentation/files/src/Drivers/Sqlite/SQL.php.txt index 5b5971e..5f120bc 100644 --- a/apiDocumentation/files/src/Drivers/Sqlite/SQL.php.txt +++ b/apiDocumentation/files/src/Drivers/Sqlite/SQL.php.txt @@ -13,6 +13,7 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query\Drivers\Sqlite; use Query\Drivers\AbstractSQL; @@ -21,8 +22,8 @@ use Query\Exception\NotImplementedException; /** * SQLite Specific SQL */ -class SQL extends AbstractSQL { - +class SQL extends AbstractSQL +{ /** * Get the query plan for the sql query */ @@ -53,7 +54,7 @@ class SQL extends AbstractSQL { */ public function tableList(): string { - return <<getDriver()->query($sql); @@ -46,9 +47,9 @@ class Util extends AbstractUtil { $outputSql = ''; // Get the data for each object - foreach($result as $r) + foreach ($result as $r) { - $sql = 'SELECT * FROM "'.$r['name'].'"'; + $sql = 'SELECT * FROM "' . $r['name'] . '"'; $res = $this->getDriver()->query($sql); $objRes = $res->fetchAll(PDO::FETCH_ASSOC); @@ -66,7 +67,7 @@ class Util extends AbstractUtil { $insertRows = []; // Create the insert statements - foreach($objRes as $row) + foreach ($objRes as $row) { $row = array_values($row); @@ -78,7 +79,7 @@ class Util extends AbstractUtil { : $this->getDriver()->quote($row[$i]); } - $rowString = 'INSERT INTO "'.$r['name'].'" ("'.implode('","', $columns).'") VALUES ('.implode(',', $row).');'; + $rowString = 'INSERT INTO "' . $r['name'] . '" ("' . implode('","', $columns) . '") VALUES (' . implode(',', $row) . ');'; unset($row); @@ -87,7 +88,7 @@ class Util extends AbstractUtil { unset($objRes); - $outputSql .= "\n\n".implode("\n", $insertRows); + $outputSql .= "\n\n" . implode("\n", $insertRows); } return $outputSql; @@ -105,11 +106,11 @@ class Util extends AbstractUtil { $sqlArray = []; - foreach($result as $r) + foreach ($result as $r) { $sqlArray[] = $r['sql']; } return implode(";\n", $sqlArray) . ';'; } -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/Exception/BadDBDriverException.php.txt b/apiDocumentation/files/src/Exception/BadDBDriverException.php.txt index be0f0fa..020291a 100644 --- a/apiDocumentation/files/src/Exception/BadDBDriverException.php.txt +++ b/apiDocumentation/files/src/Exception/BadDBDriverException.php.txt @@ -13,6 +13,7 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query\Exception; use InvalidArgumentException; @@ -20,5 +21,6 @@ use InvalidArgumentException; /** * Generic exception for bad drivers */ -class BadDBDriverException extends InvalidArgumentException { -} \ No newline at end of file +class BadDBDriverException extends InvalidArgumentException +{ +} diff --git a/apiDocumentation/files/src/Exception/NonExistentConnectionException.php.txt b/apiDocumentation/files/src/Exception/NonExistentConnectionException.php.txt index 0e80797..5ab3392 100644 --- a/apiDocumentation/files/src/Exception/NonExistentConnectionException.php.txt +++ b/apiDocumentation/files/src/Exception/NonExistentConnectionException.php.txt @@ -13,6 +13,7 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query\Exception; use InvalidArgumentException; @@ -20,5 +21,6 @@ use InvalidArgumentException; /** * Exception for missing database connection */ -class NonExistentConnectionException extends InvalidArgumentException { -} \ No newline at end of file +class NonExistentConnectionException extends InvalidArgumentException +{ +} diff --git a/apiDocumentation/files/src/Exception/NotImplementedException.php.txt b/apiDocumentation/files/src/Exception/NotImplementedException.php.txt index a0510d2..e9b3353 100644 --- a/apiDocumentation/files/src/Exception/NotImplementedException.php.txt +++ b/apiDocumentation/files/src/Exception/NotImplementedException.php.txt @@ -13,6 +13,7 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query\Exception; use BadMethodCallException; @@ -20,5 +21,6 @@ use BadMethodCallException; /** * Exception for non-implemented method */ -class NotImplementedException extends BadMethodCallException{ -} \ No newline at end of file +class NotImplementedException extends BadMethodCallException +{ +} diff --git a/apiDocumentation/files/src/JoinType.php.txt b/apiDocumentation/files/src/JoinType.php.txt index f7a9f5b..db679a3 100644 --- a/apiDocumentation/files/src/JoinType.php.txt +++ b/apiDocumentation/files/src/JoinType.php.txt @@ -13,19 +13,22 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query; /** * Enum of join types */ -enum JoinType: string { +enum JoinType: string +{ case CROSS = 'cross'; case INNER = 'inner'; case OUTER = 'outer'; case LEFT = 'left'; case RIGHT = 'right'; - public static function parse(string|self $val): self { + public static function parse(string|self $val): self + { if ($val instanceof self) { return $val; @@ -34,4 +37,3 @@ enum JoinType: string { return self::from($val); } } - diff --git a/apiDocumentation/files/src/LikeType.php.txt b/apiDocumentation/files/src/LikeType.php.txt index 5714c2a..77eee87 100644 --- a/apiDocumentation/files/src/LikeType.php.txt +++ b/apiDocumentation/files/src/LikeType.php.txt @@ -13,17 +13,20 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query; /** * 'Enum' of join types */ -enum LikeType: string { +enum LikeType: string +{ case BEFORE = 'before'; case AFTER = 'after'; case BOTH = 'both'; - public static function parse(string|self $val): self { + public static function parse(string|self $val): self + { if ($val instanceof self) { return $val; @@ -31,4 +34,4 @@ enum LikeType: string { return self::from($val); } -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/MapType.php.txt b/apiDocumentation/files/src/MapType.php.txt index d58b4e8..baaffeb 100644 --- a/apiDocumentation/files/src/MapType.php.txt +++ b/apiDocumentation/files/src/MapType.php.txt @@ -13,16 +13,18 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query; /** * Enum of query map types */ -enum MapType: string { +enum MapType: string +{ case GROUP_END = 'group_end'; case GROUP_START = 'group_start'; case JOIN = 'join'; case LIKE = 'like'; case WHERE = 'where'; case WHERE_IN = 'where_in'; -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/QueryBuilder.php.txt b/apiDocumentation/files/src/QueryBuilder.php.txt index 49fb0e5..a5c4e98 100644 --- a/apiDocumentation/files/src/QueryBuilder.php.txt +++ b/apiDocumentation/files/src/QueryBuilder.php.txt @@ -13,18 +13,20 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query; +use PDOStatement; use function is_array; use function is_int; -use function mb_trim; -use PDOStatement; +use function mb_trim; /** * Convenience class for creating sql queries */ -class QueryBuilder extends QueryBuilderBase implements QueryBuilderInterface { +class QueryBuilder extends QueryBuilderBase implements QueryBuilderInterface +{ // -------------------------------------------------------------------------- // ! Select Queries // -------------------------------------------------------------------------- @@ -68,49 +70,45 @@ class QueryBuilder extends QueryBuilderBase implements QueryBuilderInterface { /** * Selects the maximum value of a field from a query - * - * @param string|bool $as */ - public function selectMax(string $field, $as=FALSE): self + public function selectMax(string $field, bool|string $as=FALSE): self { // Create the select string - $this->state->appendSelectString(' MAX'.$this->_select($field, $as)); + $this->state->appendSelectString(' MAX' . $this->_select($field, $as)); + return $this; } /** * Selects the minimum value of a field from a query - * - * @param string|bool $as */ - public function selectMin(string $field, $as=FALSE): self + public function selectMin(string $field, bool|string $as=FALSE): self { // Create the select string - $this->state->appendSelectString(' MIN'.$this->_select($field, $as)); + $this->state->appendSelectString(' MIN' . $this->_select($field, $as)); + return $this; } /** * Selects the average value of a field from a query - * - * @param string|bool $as */ - public function selectAvg(string $field, $as=FALSE): self + public function selectAvg(string $field, bool|string $as=FALSE): self { // Create the select string - $this->state->appendSelectString(' AVG'.$this->_select($field, $as)); + $this->state->appendSelectString(' AVG' . $this->_select($field, $as)); + return $this; } /** * Selects the sum of a field from a query - * - * @param string|bool $as */ - public function selectSum(string $field, $as=FALSE): self + public function selectSum(string $field, bool|string $as=FALSE): self { // Create the select string - $this->state->appendSelectString(' SUM'.$this->_select($field, $as)); + $this->state->appendSelectString(' SUM' . $this->_select($field, $as)); + return $this; } @@ -139,6 +137,7 @@ class QueryBuilder extends QueryBuilderBase implements QueryBuilderInterface { { // Prepend the keyword to the select string $this->state->setSelectString(' DISTINCT' . $this->state->getSelectString()); + return $this; } @@ -148,6 +147,7 @@ class QueryBuilder extends QueryBuilderBase implements QueryBuilderInterface { public function explain(): self { $this->explain = TRUE; + return $this; } @@ -155,8 +155,6 @@ class QueryBuilder extends QueryBuilderBase implements QueryBuilderInterface { * Specify the database table to select from * * Alias of `from` method to better match CodeIgniter 4 - * - * @param string $tableName */ public function table(string $tableName): self { @@ -383,15 +381,15 @@ class QueryBuilder extends QueryBuilderBase implements QueryBuilderInterface { $orderClauses = []; // Flatten key/val pairs into an array of space-separated pairs - foreach($this->state->getOrderArray() as $k => $v) + foreach ($this->state->getOrderArray() as $k => $v) { - $orderClauses[] = $k . ' ' . strtoupper($v); + $orderClauses[] = $k . ' ' . strtoupper((string) $v); } // Set the final string $orderString = isset($rand) - ? "\nORDER BY".$rand - : "\nORDER BY ".implode(', ', $orderClauses); + ? "\nORDER BY" . $rand + : "\nORDER BY " . implode(', ', $orderClauses); $this->state->setOrderString($orderString); @@ -512,8 +510,9 @@ class QueryBuilder extends QueryBuilderBase implements QueryBuilderInterface { */ public function countAll(string $table): int { - $sql = 'SELECT * FROM '.$this->driver->quoteTable($table); + $sql = 'SELECT * FROM ' . $this->driver->quoteTable($table); $res = $this->driver->query($sql); + return (int) (is_countable($res->fetchAll()) ? count($res->fetchAll()) : 0); } @@ -551,7 +550,7 @@ class QueryBuilder extends QueryBuilderBase implements QueryBuilderInterface { /** * Creates and executes a batch insertion query */ - public function insertBatch(string $table, $data=[]): ?PDOStatement + public function insertBatch(string $table, mixed $data=[]): ?PDOStatement { // Get the generated values and sql string [$sql, $data] = $this->driver->insertBatch($table, $data); @@ -589,6 +588,7 @@ class QueryBuilder extends QueryBuilderBase implements QueryBuilderInterface { [$sql, $data, $affectedRows] = $this->driver->updateBatch($table, $data, $where); $this->_run(QueryType::UPDATE_BATCH, $table, $sql, $data); + return $affectedRows; } diff --git a/apiDocumentation/files/src/QueryBuilderBase.php.txt b/apiDocumentation/files/src/QueryBuilderBase.php.txt index 570380c..835f628 100644 --- a/apiDocumentation/files/src/QueryBuilderBase.php.txt +++ b/apiDocumentation/files/src/QueryBuilderBase.php.txt @@ -13,14 +13,17 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ -namespace Query; -use function regexInArray; +namespace Query; use BadMethodCallException; use PDO; + use PDOStatement; +use PHPUnit\Framework\Attributes\CodeCoverageIgnore; use Query\Drivers\DriverInterface; +use function is_string; +use function regexInArray; /** * @method affectedRows(): int @@ -56,8 +59,8 @@ use Query\Drivers\DriverInterface; * @method setTablePrefix(string $prefix): void * @method truncate(string $table): PDOStatement */ -class QueryBuilderBase { - +class QueryBuilderBase +{ /** * Convenience property for connection management */ @@ -67,7 +70,7 @@ class QueryBuilderBase { * List of queries executed */ public array $queries = [ - 'total_time' => 0 + 'total_time' => 0, ]; /** @@ -88,19 +91,13 @@ class QueryBuilderBase { // -------------------------------------------------------------------------- // ! Methods // -------------------------------------------------------------------------- - /** - * Constructor - */ public function __construct(protected ?DriverInterface $driver, protected QueryParser $parser) { // Create new State object $this->state = new State(); } - /** - * Destructor - * @codeCoverageIgnore - */ + #[CodeCoverageIgnore] public function __destruct() { $this->driver = NULL; @@ -110,8 +107,8 @@ class QueryBuilderBase { * Calls a function further down the inheritance chain. * 'Implements' methods on the driver object * - * @return mixed * @throws BadMethodCallException + * @return mixed */ public function __call(string $name, array $params) { @@ -141,7 +138,7 @@ class QueryBuilderBase { // Escape the identifiers $field = $this->driver->quoteIdent($field); - if ( ! \is_string($as)) + if ( ! is_string($as)) { // @codeCoverageIgnoreStart return $field; @@ -149,6 +146,7 @@ class QueryBuilderBase { } $as = $this->driver->quoteIdent($as); + return "({$field}) AS {$as} "; } @@ -224,7 +222,7 @@ class QueryBuilderBase { 'conjunction' => empty($this->state->getHavingMap()) ? ' HAVING ' : " {$conj} ", - 'string' => $item + 'string' => $item, ]); } @@ -242,7 +240,8 @@ class QueryBuilderBase { if (is_scalar($key)) { $pairs[$key] = $val; - } else + } + else { $pairs = $key; } @@ -300,8 +299,6 @@ class QueryBuilderBase { /** * Simplify where_in methods * - * @param mixed $key - * @param mixed $val * @param string $in - The (not) in fragment * @param string $conj - The where in conjunction */ @@ -321,10 +318,8 @@ class QueryBuilderBase { /** * Executes the compiled query - * - * @param array|null $vals */ - protected function _run(QueryType $type, string $table, string $sql = NULL, array $vals = NULL, bool $reset = TRUE): PDOStatement + protected function _run(QueryType $type, string $table, ?string $sql = NULL, ?array $vals = NULL, bool $reset = TRUE): PDOStatement { if ($sql === NULL) { @@ -346,7 +341,7 @@ class QueryBuilderBase { $totalTime = number_format($endTime - $startTime, 5); // Add this query to the list of executed queries - $this->_appendQuery($vals, $sql, (int)$totalTime); + $this->_appendQuery($vals, $sql, (int) $totalTime); // Reset class state for next query if ($reset) @@ -368,9 +363,9 @@ class QueryBuilderBase { // Quote string values foreach ($evals as &$v) { - $v = ( is_numeric($v)) + $v = (is_numeric($v)) ? $v - : htmlentities($this->driver->quote($v), ENT_NOQUOTES, 'utf-8'); + : htmlentities((string) $this->driver->quote($v), ENT_NOQUOTES, 'utf-8'); } unset($v); @@ -381,7 +376,7 @@ class QueryBuilderBase { // Add the interpreted query to the list of executed queries $this->queries[] = [ 'time' => $totalTime, - 'sql' => sprintf(...$evals) + 'sql' => sprintf(...$evals), ]; $this->queries['total_time'] += $totalTime; @@ -392,12 +387,12 @@ class QueryBuilderBase { /** * Sub-method for generating sql strings - * - * @codeCoverageIgnore */ + #[CodeCoverageIgnore] protected function _compileType(QueryType $type = QueryType::SELECT, string $table = ''): string { $setArrayKeys = $this->state->getSetArrayKeys(); + switch ($type) { case QueryType::INSERT: @@ -454,7 +449,7 @@ class QueryBuilderBase { // Set each type of subclause foreach ($clauses as $clause) { - $func = 'get' . ucFirst($clause); + $func = 'get' . ucfirst($clause); $param = $this->state->$func(); if (is_array($param)) { @@ -462,7 +457,8 @@ class QueryBuilderBase { { $sql .= $q['conjunction'] . $q['string']; } - } else + } + else { $sql .= $param; } @@ -530,4 +526,4 @@ class QueryBuilderBase { return $returningSQL; } -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/QueryBuilderInterface.php.txt b/apiDocumentation/files/src/QueryBuilderInterface.php.txt index 6716876..efe740d 100644 --- a/apiDocumentation/files/src/QueryBuilderInterface.php.txt +++ b/apiDocumentation/files/src/QueryBuilderInterface.php.txt @@ -13,6 +13,7 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query; use PDO; @@ -57,8 +58,8 @@ use PDOStatement; * @method setTablePrefix(string $prefix): void * @method truncate(string $table): PDOStatement */ -interface QueryBuilderInterface { - +interface QueryBuilderInterface +{ // -------------------------------------------------------------------------- // ! Select Queries // -------------------------------------------------------------------------- @@ -69,31 +70,23 @@ interface QueryBuilderInterface { /** * Selects the maximum value of a field from a query - * - * @param string|bool $as */ - public function selectMax(string $field, $as=FALSE): self; + public function selectMax(string $field, bool|string $as=FALSE): self; /** * Selects the minimum value of a field from a query - * - * @param string|bool $as */ - public function selectMin(string $field, $as=FALSE): self; + public function selectMin(string $field, bool|string $as=FALSE): self; /** * Selects the average value of a field from a query - * - * @param string|bool $as */ - public function selectAvg(string $field, $as=FALSE): self; + public function selectAvg(string $field, bool|string $as=FALSE): self; /** * Selects the sum of a field from a query - * - * @param string|bool $as */ - public function selectSum(string $field, $as=FALSE): self; + public function selectSum(string $field, bool|string $as=FALSE): self; /** * Adds the 'distinct' keyword to a query @@ -109,8 +102,6 @@ interface QueryBuilderInterface { * Specify the database table to select from * * Alias of `from` method to better match CodeIgniter 4 - * - * @param string $tableName */ public function table(string $tableName): self; @@ -124,29 +115,21 @@ interface QueryBuilderInterface { // -------------------------------------------------------------------------- /** * Creates a Like clause in the sql statement - * - * @param mixed $values */ public function like(string $field, mixed $values, LikeType|string $pos=LikeType::BOTH): self; /** * Generates an OR Like clause - * - * @param mixed $values */ public function orLike(string $field, mixed $values, LikeType|string $pos=LikeType::BOTH): self; /** * Generates a NOT LIKE clause - * - * @param mixed $values */ public function notLike(string $field, mixed $values, LikeType|string $pos=LikeType::BOTH): self; /** * Generates a OR NOT LIKE clause - * - * @param mixed $values */ public function orNotLike(string $field, mixed $values, LikeType|string $pos=LikeType::BOTH): self; @@ -155,17 +138,11 @@ interface QueryBuilderInterface { // -------------------------------------------------------------------------- /** * Generates a 'Having' clause - * - * @param mixed $key - * @param mixed $values */ public function having(mixed $key, mixed $values=[]): self; /** * Generates a 'Having' clause prefixed with 'OR' - * - * @param mixed $key - * @param mixed $values */ public function orHaving(mixed $key, mixed $values=[]): self; @@ -176,9 +153,6 @@ interface QueryBuilderInterface { * Specify condition(s) in the where clause of a query * Note: this function works with key / value, or a * passed array with key / value pairs - * - * @param mixed $key - * @param mixed $values */ public function where(mixed $key, mixed $values=[]): self; @@ -186,39 +160,26 @@ interface QueryBuilderInterface { * Where clause prefixed with "OR" * * @param string $key - * @param mixed $values */ public function orWhere(mixed $key, mixed $values=[]): self; /** * Where clause with 'IN' statement - * - * @param string $field - * @param mixed $values */ public function whereIn(string $field, mixed $values=[]): self; /** * Where in statement prefixed with "or" - * - * @param string $field - * @param mixed $values */ public function orWhereIn(string $field, mixed $values=[]): self; /** * WHERE NOT IN (FOO) clause - * - * @param string $field - * @param mixed $values */ public function whereNotIn(string $field, mixed $values=[]): self; /** * OR WHERE NOT IN (FOO) clause - * - * @param string $field - * @param mixed $values */ public function orWhereNotIn(string $field, mixed $values=[]): self; @@ -227,9 +188,6 @@ interface QueryBuilderInterface { // -------------------------------------------------------------------------- /** * Sets values for inserts / updates / deletes - * - * @param mixed $key - * @param mixed $values */ public function set(mixed $key, mixed $values = NULL): self; @@ -240,8 +198,6 @@ interface QueryBuilderInterface { /** * Group the results by the selected field(s) - * - * @param mixed $field */ public function groupBy(mixed $field): self; @@ -297,8 +253,6 @@ interface QueryBuilderInterface { /** * Convenience method for get() with a where clause - * - * @param array $where */ public function getWhere(string $table, array $where=[], ?int $limit=NULL, ?int $offset=NULL): PDOStatement; @@ -317,8 +271,6 @@ interface QueryBuilderInterface { /** * Creates an insert clause, and executes it - * - * @param mixed $data */ public function insert(string $table, mixed $data=[]): PDOStatement; @@ -331,8 +283,6 @@ interface QueryBuilderInterface { /** * Creates an update clause, and executes it - * - * @param mixed $data */ public function update(string $table, mixed $data=[]): PDOStatement; @@ -348,8 +298,6 @@ interface QueryBuilderInterface { /** * Deletes data from a table - * - * @param mixed $where */ public function delete(string $table, mixed $where=''): PDOStatement; diff --git a/apiDocumentation/files/src/QueryParser.php.txt b/apiDocumentation/files/src/QueryParser.php.txt index 2c723c9..9a175b5 100644 --- a/apiDocumentation/files/src/QueryParser.php.txt +++ b/apiDocumentation/files/src/QueryParser.php.txt @@ -13,6 +13,7 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query; use Query\Drivers\DriverInterface; @@ -20,17 +21,8 @@ use Query\Drivers\DriverInterface; /** * Utility Class to parse sql clauses for properly escaping identifiers */ -class QueryParser { - - /** - * Regex patterns for various syntax components - */ - private array $matchPatterns = [ - 'function' => '([a-zA-Z0-9_]+\((.*?)\))', - 'identifier' => '([a-zA-Z0-9_-]+\.?)+', - 'operator' => '=|AND|&&?|~|\|\|?|\^|/|>=?|<=?|-|%|OR|\+|NOT|\!=?|<>|XOR' - ]; - +class QueryParser +{ /** * Regex matches */ @@ -41,6 +33,15 @@ class QueryParser { 'combined' => [], ]; + /** + * Regex patterns for various syntax components + */ + private array $matchPatterns = [ + 'function' => '([a-zA-Z0-9_]+\((.*?)\))', + 'identifier' => '([a-zA-Z0-9_-]+\.?)+', + 'operator' => '=|AND|&&?|~|\|\|?|\^|/|>=?|<=?|-|%|OR|\+|NOT|\!=?|<>|XOR', + ]; + /** * Constructor/entry point into parser */ @@ -56,16 +57,16 @@ class QueryParser { public function parseJoin(string $sql): array { // Get sql clause components - preg_match_all('`'.$this->matchPatterns['function'].'`', $sql, $this->matches['functions'], PREG_SET_ORDER); - preg_match_all('`'.$this->matchPatterns['identifier'].'`', $sql, $this->matches['identifiers'], PREG_SET_ORDER); - preg_match_all('`'.$this->matchPatterns['operator'].'`', $sql, $this->matches['operators'], PREG_SET_ORDER); + preg_match_all('`' . $this->matchPatterns['function'] . '`', $sql, $this->matches['functions'], PREG_SET_ORDER); + preg_match_all('`' . $this->matchPatterns['identifier'] . '`', $sql, $this->matches['identifiers'], PREG_SET_ORDER); + preg_match_all('`' . $this->matchPatterns['operator'] . '`', $sql, $this->matches['operators'], PREG_SET_ORDER); // Get everything at once for ordering - $fullPattern = '`'.$this->matchPatterns['function'].'+|'.$this->matchPatterns['identifier'].'|('.$this->matchPatterns['operator'].')+`i'; + $fullPattern = '`' . $this->matchPatterns['function'] . '+|' . $this->matchPatterns['identifier'] . '|(' . $this->matchPatterns['operator'] . ')+`i'; preg_match_all($fullPattern, $sql, $this->matches['combined'], PREG_SET_ORDER); // Go through the matches, and get the most relevant matches - $this->matches = array_map([$this, 'filterArray'], $this->matches); + $this->matches = array_map($this->filterArray(...), $this->matches); return $this->matches; } @@ -79,9 +80,9 @@ class QueryParser { $count = is_countable($parts['identifiers']) ? count($parts['identifiers']) : 0; // Go through and quote the identifiers - for($i=0; $i <= $count; $i++) + for ($i=0; $i <= $count; $i++) { - if (in_array($parts['combined'][$i], $parts['identifiers']) && ! is_numeric($parts['combined'][$i])) + if (in_array($parts['combined'][$i], $parts['identifiers'], TRUE) && ! is_numeric($parts['combined'][$i])) { $parts['combined'][$i] = $this->db->quoteIdent($parts['combined'][$i]); } @@ -92,18 +93,16 @@ class QueryParser { /** * Returns a more useful match array - * - * @return array */ protected function filterArray(array $array): array { $newArray = []; - foreach($array as $row) + foreach ($array as $row) { $newArray[] = (is_array($row)) ? $row[0] : $row; } return $newArray; } -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/QueryType.php.txt b/apiDocumentation/files/src/QueryType.php.txt index 36b118d..6e6550e 100644 --- a/apiDocumentation/files/src/QueryType.php.txt +++ b/apiDocumentation/files/src/QueryType.php.txt @@ -13,16 +13,18 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query; /** * Enum of query types */ -enum QueryType: string { +enum QueryType: string +{ case SELECT = 'select'; case INSERT = 'insert'; case INSERT_BATCH = 'insert_batch'; case UPDATE = 'update'; case UPDATE_BATCH = 'update_batch'; case DELETE = 'delete'; -} \ No newline at end of file +} diff --git a/apiDocumentation/files/src/State.php.txt b/apiDocumentation/files/src/State.php.txt index 25a2df5..0ab91af 100644 --- a/apiDocumentation/files/src/State.php.txt +++ b/apiDocumentation/files/src/State.php.txt @@ -13,6 +13,7 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ + namespace Query; use function is_array; @@ -20,32 +21,33 @@ use function is_array; /** * Query builder state * - * @method getSelectString(): string * @method getFromString(): string - * @method getSetString(): string - * @method getOrderString(): string - * @method getGroupString(): string - * @method getSetArrayKeys(): array - * @method getOrderArray(): array * @method getGroupArray(): array - * @method getValues(): array - * @method getWhereValues(): array + * @method getGroupString(): string + * @method getHavingMap(): array * @method getLimit(): int|null * @method getOffset() + * @method getOrderArray(): array + * @method getOrderString(): string * @method getQueryMap(): array - * @method getHavingMap(): array + * @method getSelectString(): string + * @method getSetArrayKeys(): array + * @method getSetString(): string + * @method getValues(): array + * @method getWhereValues(): array * - * @method setSelectString(string $selectString): self * @method setFromString(string $fromString): self - * @method setSetString(string $setString): self - * @method setOrderString(string $orderString): self - * @method setGroupString(string $groupString): self - * @method setSetArrayKeys(array $arrayKeys): self * @method setGroupArray(array $array): self + * @method setGroupString(string $groupString): self * @method setLimit(int $limit): self * @method setOffset(?int $offset): self + * @method setOrderString(string $orderString): self + * @method setSelectString(string $selectString): self + * @method setSetArrayKeys(array $arrayKeys): self + * @method setSetString(string $setString): self */ -class State { +class State +{ // -------------------------------------------------------------------------- // ! SQL Clause Strings // -------------------------------------------------------------------------- @@ -150,6 +152,7 @@ class State { if (isset($this->$maybeProp)) { $this->$maybeProp = $arguments[0]; + return $this; } } @@ -160,30 +163,35 @@ class State { public function appendSelectString(string $str): self { $this->selectString .= $str; + return $this; } public function appendSetArrayKeys(array $setArrayKeys): self { $this->setArrayKeys = array_merge($this->setArrayKeys, $setArrayKeys); + return $this; } public function setOrderArray(string $key, mixed $orderArray): self { $this->orderArray[$key] = $orderArray; + return $this; } public function appendGroupArray(string $groupArray): self { $this->groupArray[] = $groupArray; + return $this; } public function appendValues(array $values): self { $this->values = array_merge($this->values, $values); + return $this; } @@ -191,7 +199,7 @@ class State { { if (is_array($val)) { - foreach($val as $v) + foreach ($val as $v) { $this->whereValues[] = $v; } @@ -200,6 +208,7 @@ class State { } $this->whereValues[] = $val; + return $this; } @@ -211,14 +220,16 @@ class State { $this->queryMap[] = [ 'type' => $type, 'conjunction' => $conjunction, - 'string' => $string + 'string' => $string, ]; + return $this; } public function appendHavingMap(array $item): self { $this->havingMap[] = $item; + return $this; } } diff --git a/apiDocumentation/files/src/common.php.txt b/apiDocumentation/files/src/common.php.txt index fbb0859..d7b7d08 100644 --- a/apiDocumentation/files/src/common.php.txt +++ b/apiDocumentation/files/src/common.php.txt @@ -13,112 +13,109 @@ * @link https://git.timshomepage.net/aviat/Query * @version 4.0.0 */ -namespace { - use Query\ConnectionManager; - use Query\QueryBuilderInterface; +use Query\{ConnectionManager, QueryBuilderInterface}; - /** - * Global functions that don't really fit anywhere else - */ - /** - * Multibyte-safe trim function - */ - function mb_trim(string $string): string +/** + * Global functions that don't really fit anywhere else + */ +/** + * Multibyte-safe trim function + */ +function mb_trim(string $string): string +{ + return preg_replace('/(^\s+)|(\s+$)/u', '', $string); +} + +/** + * Filter out db rows into one array + */ +function dbFilter(array $array, mixed $index): array +{ + $newArray = []; + + foreach ($array as $a) { - return preg_replace('/(^\s+)|(\s+$)/u', '', $string); + $newArray[] = $a[$index]; } - /** - * Filter out db rows into one array - */ - function dbFilter(array $array, mixed $index): array + return $newArray; +} + +/** + * Zip a set of arrays together on common keys + * + * The $zipperInput array is an array of arrays indexed by their place in the output + * array. + */ +function arrayZipper(array $zipperInput): array +{ + $output = []; + + foreach ($zipperInput as $appendKey => $values) { - $newArray = []; - - foreach ($array as $a) + foreach ($values as $index => $value) { - $newArray[] = $a[$index]; - } - - return $newArray; - } - - /** - * Zip a set of arrays together on common keys - * - * The $zipperInput array is an array of arrays indexed by their place in the output - * array. - */ - function arrayZipper(array $zipperInput): array - { - $output = []; - - foreach ($zipperInput as $appendKey => $values) - { - foreach ($values as $index => $value) + if ( ! isset($output[$index])) { - if ( ! isset($output[$index])) - { - $output[$index] = []; - } - $output[$index][$appendKey] = $value; + $output[$index] = []; } + $output[$index][$appendKey] = $value; } - - return $output; } - /** - * Determine whether a value in the passed array matches the pattern - * passed - */ - function regexInArray(array $array, string $pattern): bool + return $output; +} + +/** + * Determine whether a value in the passed array matches the pattern + * passed + */ +function regexInArray(array $array, string $pattern): bool +{ + if (empty($array)) { - if (empty($array)) - { - return FALSE; - } - - foreach ($array as $item) - { - if (is_scalar($item) && preg_match($pattern, (string) $item)) - { - return TRUE; - } - } - return FALSE; } - /** - * Connection function - * - * Send an array or object as connection parameters to create a connection. If - * the array or object has an 'alias' parameter, passing that string to this - * function will return that connection. Passing no parameters returns the last - * connection created. - */ - function Query(string|object|array|null $params = ''): ?QueryBuilderInterface - + foreach ($array as $item) { - if ($params === NULL) + if (is_scalar($item) && preg_match($pattern, (string) $item)) { - return NULL; + return TRUE; } - - $manager = ConnectionManager::getInstance(); - - // If you are getting a previously created connection - if (is_string($params)) - { - return $manager->getConnection($params); - } - - $paramsObject = (object)$params; - - // Otherwise, return a new connection - return $manager->connect($paramsObject); } + + return FALSE; } + +/** + * Connection function + * + * Send an array or object as connection parameters to create a connection. If + * the array or object has an 'alias' parameter, passing that string to this + * function will return that connection. Passing no parameters returns the last + * connection created. + */ +function Query(string|object|array|null $params = ''): ?QueryBuilderInterface +{ + if ($params === NULL) + { + return NULL; + } + + $manager = ConnectionManager::getInstance(); + + // If you are getting a previously created connection + if (is_string($params)) + { + return $manager->getConnection($params); + } + + $paramsObject = (object) $params; + + // Otherwise, return a new connection + return $manager->connect($paramsObject); +} + // End of common.php diff --git a/apiDocumentation/graphs/classes.svg b/apiDocumentation/graphs/classes.svg index fe24224..e2125ea 100644 --- a/apiDocumentation/graphs/classes.svg +++ b/apiDocumentation/graphs/classes.svg @@ -31,23 +31,23 @@ class Query\\Exception\\NotImplementedException-->PDOInvalidArgumentExceptionBadMethodCallException - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -