Settings.php
4 years ago
WordPress.php
4 years ago
WordPressDbStatement.php
4 years ago
WordPressTracker.php
4 years ago
WordPressDbStatement.php
74 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Matomo - free/libre analytics platform |
| 4 | * |
| 5 | * @link https://matomo.org |
| 6 | * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 7 | * @package matomo |
| 8 | */ |
| 9 | |
| 10 | namespace Piwik\Db\Adapter; |
| 11 | |
| 12 | use Zend_Db_Statement; |
| 13 | |
| 14 | if ( ! defined( 'ABSPATH' ) ) { |
| 15 | exit; // if accessed directly |
| 16 | } |
| 17 | /** |
| 18 | * We want a real data, not something coming from cache |
| 19 | * phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching |
| 20 | * |
| 21 | * This is a report error, so silent the possible errors |
| 22 | * phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged |
| 23 | * |
| 24 | * We cannot use parameters of statements as this is the table names we build |
| 25 | * phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery |
| 26 | * phpcs:disable WordPress.DB.PreparedSQL.NotPrepared |
| 27 | */ |
| 28 | class WordPressDbStatement extends Zend_Db_Statement { |
| 29 | private $result; |
| 30 | private $sql; |
| 31 | |
| 32 | public function __construct( $adapter, $sql, $result ) { |
| 33 | $this->result = $result; |
| 34 | $this->_adapter = $adapter; |
| 35 | $this->sql = $sql; |
| 36 | } |
| 37 | |
| 38 | public function closeCursor() { |
| 39 | // not needed |
| 40 | } |
| 41 | |
| 42 | public function columnCount() { |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | public function errorCode() { |
| 47 | // not needed |
| 48 | } |
| 49 | |
| 50 | public function errorInfo() { |
| 51 | // not needed |
| 52 | } |
| 53 | |
| 54 | public function fetch( $style = null, $cursor = null, $offset = null ) { |
| 55 | if ( is_array( $this->result ) && ! empty( $this->result ) ) { |
| 56 | return array_shift( $this->result ); |
| 57 | } |
| 58 | |
| 59 | return $this->result; |
| 60 | } |
| 61 | |
| 62 | public function nextRowset() { |
| 63 | // not needed |
| 64 | } |
| 65 | |
| 66 | public function rowCount() { |
| 67 | if ( is_array( $this->result ) ) { |
| 68 | return count( $this->result ); |
| 69 | } |
| 70 | |
| 71 | return $this->result; |
| 72 | } |
| 73 | } |
| 74 |