Skip to content

Commit 77a6dc1

Browse files
author
Eugene Ritter
committed
Removed fetchObject() and fetchAllObjects(). Left fetchColumn(), fetchAssoc().
1 parent f524dcb commit 77a6dc1

File tree

3 files changed

+6
-114
lines changed

3 files changed

+6
-114
lines changed

src/Database/Statement/BufferedStatement.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,6 @@ public function fetchAssoc()
114114
return $this->fetch(static::FETCH_TYPE_ASSOC);
115115
}
116116

117-
/**
118-
* {@inheritdoc}
119-
*/
120-
public function fetchObject()
121-
{
122-
return $this->fetch(static::FETCH_TYPE_OBJ);
123-
}
124-
125117
/**
126118
* {@inheritDoc}
127119
*

src/Database/Statement/StatementDecorator.php

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ class StatementDecorator implements StatementInterface, Countable, IteratorAggre
4747
* @var string
4848
*/
4949
const FETCH_TYPE_ASSOC = 'assoc';
50-
/**
51-
* Used to designate that objects of \stdClass be returned in a result when calling fetch methods
52-
*
53-
* @var string
54-
*/
55-
const FETCH_TYPE_OBJ = 'obj';
5650

5751
/**
5852
* Statement instance implementation, such as PDOStatement
@@ -215,16 +209,6 @@ public function fetch($type = self::FETCH_TYPE_NUM)
215209
return $this->_statement->fetch($type);
216210
}
217211

218-
/**
219-
* Returns the next row as a stdClass object
220-
*
221-
* @return array|false Result array containing columns and values in an anonymous object or false if no results
222-
*/
223-
public function fetchObject()
224-
{
225-
return $this->fetch(static::FETCH_TYPE_OBJ);
226-
}
227-
228212
/**
229213
* @return array|false Result array containing columns and values an an associative array or false if no results
230214
*/
@@ -268,16 +252,6 @@ public function fetchAll($type = self::FETCH_TYPE_NUM)
268252
return $this->_statement->fetchAll($type);
269253
}
270254

271-
/**
272-
* Returns an array of \stdClass objects or false
273-
*
274-
* @return \stdClass[]|false
275-
*/
276-
public function fetchAllObjects()
277-
{
278-
return $this->fetchAll(static::FETCH_TYPE_OBJ);
279-
}
280-
281255
/**
282256
* Returns the number of rows affected by this SQL statement.
283257
*

tests/TestCase/Database/QueryTest.php

Lines changed: 6 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -4530,34 +4530,6 @@ public function testDeleteModifiers()
45304530
);
45314531
}
45324532

4533-
/**
4534-
* Tests that fetch returns an anonymous object when the string 'obj'
4535-
* is passed as an argument
4536-
*
4537-
* @return void
4538-
*/
4539-
public function testSelectWithObjFetchType()
4540-
{
4541-
$this->loadFixtures('Comments');
4542-
$query = new Query($this->connection);
4543-
$result = $query
4544-
->select(['id'])
4545-
->from('comments')
4546-
->where(['id' => '1'])
4547-
->execute();
4548-
$obj = (object)['id' => 1];
4549-
$this->assertEquals($obj, $result->fetch('obj'));
4550-
4551-
$query = new Query($this->connection);
4552-
$result = $query
4553-
->select(['id'])
4554-
->from('comments')
4555-
->where(['id' => '1'])
4556-
->execute();
4557-
$rows = $result->fetchAll('obj');
4558-
$this->assertEquals($obj, $rows[0]);
4559-
}
4560-
45614533
/**
45624534
* Test getValueBinder()
45634535
*
@@ -4701,6 +4673,7 @@ public function assertQuotedQuery($pattern, $query, $optional = false)
47014673
/**
47024674
* Test that calling fetchAssoc return an associated array.
47034675
* @return void
4676+
* @throws \Exception
47044677
*/
47054678
public function testFetchAssoc()
47064679
{
@@ -4720,34 +4693,8 @@ public function testFetchAssoc()
47204693
}
47214694

47224695
/**
4723-
* Test that calling fetchObject returns a \stdClass object
4724-
* @return void
4725-
*/
4726-
public function testFetchObject()
4727-
{
4728-
$this->loadFixtures('Profiles');
4729-
$query = new Query($this->connection);
4730-
$results = $query
4731-
->select([
4732-
'id',
4733-
'user_id',
4734-
'is_active'
4735-
])
4736-
->from('profiles')
4737-
->limit(1)
4738-
->execute()
4739-
->fetchObject();
4740-
$this->assertInstanceOf(\stdClass::class, $results);
4741-
$this->assertObjectHasAttribute('id', $results);
4742-
$this->assertObjectHasAttribute('user_id', $results);
4743-
$this->assertObjectHasAttribute('is_active', $results);
4744-
$this->assertEquals($results->id, '1');
4745-
$this->assertEquals($results->user_id, '1');
4746-
$this->assertEquals($results->is_active, '0');
4747-
}
4748-
4749-
/**
4750-
* Test that calling fetchColumn returns the correct column value.
4696+
* Test that fetchColumn() will return the correct value at $position.
4697+
* @throws \Exception
47514698
* @return void
47524699
*/
47534700
public function testFetchColumn()
@@ -4772,8 +4719,9 @@ public function testFetchColumn()
47724719
* Test that calling fetchAssoc, fetchColum and fetchObject in sequence
47734720
* alters the fetched data to the correct types and values.
47744721
* @return void
4722+
* @throws \Exception
47754723
*/
4776-
public function testFetchAllAssocColumnAndObj()
4724+
public function testFetchAllAssocColumn()
47774725
{
47784726
$this->loadFixtures('Profiles');
47794727
$query = new Query($this->connection);
@@ -4791,28 +4739,6 @@ public function testFetchAllAssocColumnAndObj()
47914739
$this->assertEquals('2', $results['id']);
47924740
$results = $statement->fetchColumn(0);
47934741
$this->assertEquals('3', $results[0]);
4794-
$results = $statement->fetchObject();
4795-
$this->assertEquals('4', $results->id);
4796-
}
4797-
4798-
/**
4799-
* Test that an array of objects is returned
4800-
* @return void
4801-
*/
4802-
public function testFetchAllObjects()
4803-
{
4804-
$this->loadFixtures('Profiles');
4805-
$query = new Query($this->connection);
4806-
$query
4807-
->select([
4808-
'id',
4809-
'user_id',
4810-
'is_active'
4811-
])
4812-
->from('profiles');
4813-
$statement = $query->execute();
4814-
$results = $statement->fetchAllObjects();
4815-
$this->assertInstanceOf(\stdClass::class, $results[0]);
4816-
$this->assertEquals('2', $results[1]->id);
48174742
}
48184743
}
4744+

0 commit comments

Comments
 (0)