• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aimeos / aimeos-base / 2b67f008-102f-4100-8c18-9e33496e5a87

16 Oct 2024 09:01AM UTC coverage: 88.603% (-0.02%) from 88.621%
2b67f008-102f-4100-8c18-9e33496e5a87

push

circleci

aimeos
Support for Doctrine DBAL 4.x, dropped support for 2.x

18 of 28 new or added lines in 4 files covered. (64.29%)

3 existing lines in 2 files now uncovered.

1687 of 1904 relevant lines covered (88.6%)

5.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.33
/src/DB/Result/DBAL.php
1
<?php
2

3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021-2024
6
 * @package Base
7
 * @subpackage DB
8
 */
9

10

11
namespace Aimeos\Base\DB\Result;
12

13

14
/**
15
 * Database result set object for DBAL connections.
16
 *
17
 * @package Base
18
 * @subpackage DB
19
 */
20
class DBAL extends \Aimeos\Base\DB\Result\Base implements \Aimeos\Base\DB\Result\Iface
21
{
22
        private $result;
23

24

25
        /**
26
         * Initializes the result object.
27
         *
28
         * @param \Doctrine\DBAL\Driver\Statement|\Doctrine\DBAL\Driver\Result $result Result object created by DBAL
29
         */
30
        public function __construct( $result )
31
        {
32
                $this->result = $result;
33✔
33
        }
34

35

36
        /**
37
         * Clears the result set if anything is left.
38
         */
39
        public function __destruct()
40
        {
41
                $class = '\Doctrine\DBAL\Driver\Result';
33✔
42

43
                if( $this->result instanceof $class ) {
33✔
UNCOV
44
                        $this->result->free();
×
45
                }
46

47
                $class = '\Doctrine\DBAL\Driver\Statement';
33✔
48

49
                if( $this->result instanceof $class ) {
33✔
50
                        $this->result->closeCursor();
×
51
                }
52
        }
53

54

55
        /**
56
         * Returns the number of rows affected by a INSERT, UPDATE or DELETE statement.
57
         *
58
         * @return int Number of touched records
59
         * @throws \Aimeos\Base\DB\Exception if an error occured in the unterlying driver
60
         */
61
        public function affectedRows() : int
62
        {
63
                try {
64
                        return $this->result->rowCount();
2✔
NEW
65
                } catch( \PDOException $e ) {
×
66
                        throw new \Aimeos\Base\DB\Exception( $e->getMessage(), $e->getCode() );
×
67
                }
68
        }
69

70

71
        /**
72
         * Retrieves the next row from database result set.
73
         *
74
         * @param int $style The data can be returned as associative or numerical array
75
         * @return array|null Numeric or associative array of columns returned by the database or null if no more rows are available
76
         * @throws \Aimeos\Base\DB\Exception if an error occured in the unterlying driver or the fetch style is unknown
77
         */
78
        public function fetch( int $style = \Aimeos\Base\DB\Result\Base::FETCH_ASSOC ) : ?array
79
        {
80
                try
81
                {
82
                        $fetch = $style === \Aimeos\Base\DB\Result\Base::FETCH_NUM ? \PDO::FETCH_NUM : \PDO::FETCH_ASSOC;
22✔
83
                        return $this->result->fetch( $fetch ) ?: null;
22✔
84
                }
NEW
85
                catch( \PDOException $e )
×
86
                {
87
                        throw new \Aimeos\Base\DB\Exception( $e->getMessage(), $e->getCode() );
×
88
                }
89
        }
90

91

92
        /**
93
         * Cleans up pending database result sets.
94
         *
95
         * @return \Aimeos\Base\DB\Result\Iface Result instance for method chaining
96
         * @throws \Aimeos\Base\DB\Exception if an error occured in the unterlying driver
97
         */
98
        public function finish() : Iface
99
        {
100
                try
101
                {
102
                        $class = '\Doctrine\DBAL\Driver\Result';
33✔
103

104
                        if( $this->result instanceof $class ) {
33✔
UNCOV
105
                                $this->result->free();
×
106
                        }
107

108
                        $class = '\Doctrine\DBAL\Driver\Statement';
33✔
109

110
                        if( $this->result instanceof $class ) {
33✔
111
                                $this->result->closeCursor();
33✔
112
                        }
113
                }
NEW
114
                catch( \PDOException $e )
×
115
                {
116
                        throw new \Aimeos\Base\DB\Exception( $e->getMessage(), $e->getCode() );
×
117
                }
118

119
                return $this;
33✔
120
        }
121

122

123
        /**
124
         * Retrieves the next database result set.
125
         *
126
         * @return bool True if another result is available, false if not
127
         */
128
        public function nextResult() : bool
129
        {
130
                return false;
×
131
        }
132
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc