From 5aa52f13436065bce09fe910dd9c8e5f00dfcff7 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Wed, 21 Dec 2016 14:48:26 +1300 Subject: [PATCH] Revert "Optimised keyedColumn() and map() for MySQLQuery" --- src/ORM/Connect/MySQLQuery.php | 36 --------------------------------- tests/php/ORM/DataQueryTest.php | 18 ----------------- 2 files changed, 54 deletions(-) diff --git a/src/ORM/Connect/MySQLQuery.php b/src/ORM/Connect/MySQLQuery.php index 7a4634a9d..5db16a270 100644 --- a/src/ORM/Connect/MySQLQuery.php +++ b/src/ORM/Connect/MySQLQuery.php @@ -60,40 +60,4 @@ class MySQLQuery extends Query return false; } } - - /** - * Return an array containing all values in the leftmost column, where the keys are the - * same as the values. - * - * @return array - */ - public function keyedColumn() - { - $column = []; - if (is_object($this->handle)) { - foreach ($this->handle->fetch_all(MYSQLI_ASSOC) as $record) { - $val = $record[key($record)]; - $column[$val] = $val; - } - } - return $column; - } - - /** - * Return a map from the first column to the second column. - * - * @return array - */ - public function map() - { - $column = []; - if (is_object($this->handle)) { - foreach ($this->handle->fetch_all(MYSQLI_ASSOC) as $record) { - $key = reset($record); - $val = next($record); - $column[$key] = $val; - } - } - return $column; - } } diff --git a/tests/php/ORM/DataQueryTest.php b/tests/php/ORM/DataQueryTest.php index a92f1c7bb..a29d02e98 100644 --- a/tests/php/ORM/DataQueryTest.php +++ b/tests/php/ORM/DataQueryTest.php @@ -336,24 +336,6 @@ class DataQueryTest extends SapphireTest $this->resetDBSchema(true); } - public function testMap() - { - $fixtures = DataQueryTest\ObjectC::get(); - $expected = array(); - foreach ($fixtures as $fixture) { - $expected[$fixture->ID] = $fixture->Title; - $fixture->destroy(); - } - $result = DB::query("SELECT \"ID\", \"Title\" FROM \"DataQueryTest_C\"")->map(); - $this->assertEquals($expected, $result); - } - - public function testKeyedColumn() - { - $result = DB::query("SELECT \"Title\" FROM \"DataQueryTest_C\"")->keyedColumn(); - $this->assertEquals(['First' => 'First', 'Second' => 'Second', 'Last' => 'Last'], $result); - } - /** * Tests that getFinalisedQuery can include all tables */