Code Duplication    Length = 16-19 lines in 2 locations

includes/db/DatabasePostgres.php 1 location

@@ 616-631 (lines=16) @@
613
	 * @param array $options
614
	 * @return int
615
	 */
616
	function estimateRowCount( $table, $vars = '*', $conds = '',
617
		$fname = __METHOD__, $options = []
618
	) {
619
		$options['EXPLAIN'] = true;
620
		$res = $this->select( $table, $vars, $conds, $fname, $options );
621
		$rows = -1;
622
		if ( $res ) {
623
			$row = $this->fetchRow( $res );
624
			$count = [];
625
			if ( preg_match( '/rows=(\d+)/', $row[0], $count ) ) {
626
				$rows = (int)$count[1];
627
			}
628
		}
629
630
		return $rows;
631
	}
632
633
	/**
634
	 * Returns information about an index

includes/db/DatabaseMssql.php 1 location

@@ 512-530 (lines=19) @@
509
	 * @param array $options
510
	 * @return int
511
	 */
512
	public function estimateRowCount( $table, $vars = '*', $conds = '',
513
		$fname = __METHOD__, $options = []
514
	) {
515
		// http://msdn2.microsoft.com/en-us/library/aa259203.aspx
516
		$options['EXPLAIN'] = true;
517
		$options['FOR COUNT'] = true;
518
		$res = $this->select( $table, $vars, $conds, $fname, $options );
519
520
		$rows = -1;
521
		if ( $res ) {
522
			$row = $this->fetchRow( $res );
523
524
			if ( isset( $row['EstimateRows'] ) ) {
525
				$rows = (int)$row['EstimateRows'];
526
			}
527
		}
528
529
		return $rows;
530
	}
531
532
	/**
533
	 * Returns information about an index