diff --git a/src/Environment.php b/src/Environment.php index fc804c3..dd043c3 100755 --- a/src/Environment.php +++ b/src/Environment.php @@ -897,7 +897,7 @@ private function query_insert($query) return $this->set_error('Invalid INSERT Query '); $result = $this->query_select($the_rest); $dataRows = []; - while (($values = $result->fetchRow()) !== null) { + while (($values = $result->fetch_row()) !== null) { $row = array_map( function ($value) { if (is_string($value)) $value = "'$value'"; @@ -2427,27 +2427,27 @@ private function parse_trim_function($join_info, $where_type, $paramsStr) public function fetch_all(ResultSet $results, $type = ResultSet::FETCH_ASSOC) { - return $results->fetchAll($type); + return $results->fetch_all($type); } public function fetch_array(ResultSet $results, $type = ResultSet::FETCH_ASSOC) { - return $results->fetchArray($type); + return $results->fetch_array($type); } public function fetch_assoc(ResultSet $results) { - return $results->fetchAssoc(); + return $results->fetch_assoc(); } public function fetch_row(ResultSet $results) { - return $results->fetchRow(); + return $results->fetch_row(); } public function fetch_both(ResultSet $results) { - return $results->fetchBoth(); + return $results->fetch_both(); } public function fetch_single(ResultSet $results, $column = 0) @@ -2457,32 +2457,32 @@ public function fetch_single(ResultSet $results, $column = 0) public function fetch_object(ResultSet $results) { - return $results->fetchObject(); + return $results->fetch_object(); } public function data_seek(ResultSet $results, $i) { - return $results->dataSeek($i); + return $results->data_seek($i); } public function num_rows(ResultSet $results) { - return $results->numRows(); + return $results->num_rows(); } public function num_fields(ResultSet $results) { - return $results->numFields(); + return $results->field_count(); } public function fetch_field(ResultSet $results) { - return $results->fetchField(); + return $results->fetch_field(); } public function field_seek(ResultSet $results, $i) { - return $results->fieldSeek($i); + return $results->field_seek($i); } public function free_result(ResultSet $results) diff --git a/src/ResultSet.php b/src/ResultSet.php index c409963..689d3e1 100644 --- a/src/ResultSet.php +++ b/src/ResultSet.php @@ -23,12 +23,12 @@ public function __construct(array $columnNames, array $data) $this->dataCursor = new TableCursor($data); } - public function createMetadata() + public function create_metadata() { return new ResultSet($this->columnNames, []); } - public function fetchAll($type = self::FETCH_ASSOC) + public function fetch_all($type = self::FETCH_ASSOC) { if ($type === self::FETCH_NUM) { return $this->data; @@ -49,7 +49,7 @@ public function fetchAll($type = self::FETCH_ASSOC) return $result_array; } - public function fetchArray($type = self::FETCH_ASSOC) + public function fetch_array($type = self::FETCH_ASSOC) { if (!$this->dataCursor->valid()) { return null; @@ -66,32 +66,32 @@ public function fetchArray($type = self::FETCH_ASSOC) } } - public function fetchAssoc() + public function fetch_assoc() { - return $this->fetchArray(self::FETCH_ASSOC); + return $this->fetch_array(self::FETCH_ASSOC); } - public function fetchRow() + public function fetch_row() { - return $this->fetchArray(self::FETCH_NUM); + return $this->fetch_array(self::FETCH_NUM); } - public function fetchBoth() + public function fetch_both() { - return $this->fetchArray(self::FETCH_BOTH); + return $this->fetch_array(self::FETCH_BOTH); } public function fetchSingle($column = 0) { $type = is_numeric($column) ? self::FETCH_NUM : self::FETCH_ASSOC; - $row = $this->fetchArray($type); + $row = $this->fetch_array($type); return $row !== null && array_key_exists($column, $row) ? $row[$column] : null; } - public function fetchObject() + public function fetch_object() { - $row = $this->fetchAssoc(); + $row = $this->fetch_assoc(); if ($row === null) { return null; } @@ -99,22 +99,22 @@ public function fetchObject() return (object) $row; } - public function dataSeek($i) + public function data_seek($i) { return $this->dataCursor->seek($i); } - public function numRows() + public function num_rows() { return $this->dataCursor->count(); } - public function numFields() + public function field_count() { return count($this->columnNames); } - public function fetchField() + public function fetch_field() { $pos = $this->columnsIndex; if (!isset($this->columnNames[$pos])) { @@ -127,7 +127,7 @@ public function fetchField() return $field; } - public function fieldSeek($i) + public function field_seek($i) { if (!isset($this->columnNames[$i])) { return false; diff --git a/src/Statement.php b/src/Statement.php index 78bdd82..ab133f5 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -84,7 +84,7 @@ public function field_count() return $this->set_error("Unable to perform a field_count without a prepare"); } - return $this->result->numFields(); + return $this->result->field_count(); } public function data_seek($offset) @@ -95,7 +95,7 @@ public function data_seek($offset) return $this->set_error("Unable to perform a data_seek without a store_result"); } - $result = $this->result->dataSeek($offset); + $result = $this->result->data_seek($offset); return $result !== false; } @@ -107,7 +107,7 @@ public function num_rows() return $this->set_error("Unable to perform a num_rows without a store_result"); } - return $this->result->numRows(); + return $this->result->num_rows(); } public function bind_param($types, &...$params) @@ -187,7 +187,7 @@ function($match) use ($parameters, &$count) { return $parameters[$count++]; }, $result = $this->environment->query($realQuery); if($result instanceof ResultSet) { $this->result = $result; - $this->metadata = $result->createMetadata(); + $this->metadata = $result->create_metadata(); return true; } else if($result === false) { return $this->set_error(trim($this->environment->error())); @@ -206,7 +206,7 @@ public function fetch() return $this->set_error("Unable to perform a fetch without a bind_result"); } - $result = $this->result->fetchRow(); + $result = $this->result->fetch_row(); if($result !== null) { $i = 0; foreach ($result as $value) { diff --git a/tests/ResultSetTest.php b/tests/ResultSetTest.php index 9988be2..3f11440 100644 --- a/tests/ResultSetTest.php +++ b/tests/ResultSetTest.php @@ -21,28 +21,28 @@ class ResultSetTest extends BaseTest array(10, 'jon', 'doe', 'new york'), ); - public function testFetchAllEmpty() + public function testfetch_allEmpty() { $empty = array(); $results = new ResultSet(array('myColumn'), $empty); - $this->assertEquals($empty, $results->fetchAll(ResultSet::FETCH_NUM)); - $this->assertEquals($empty, $results->fetchAll(ResultSet::FETCH_ASSOC)); - $this->assertEquals($empty, $results->fetchAll(ResultSet::FETCH_BOTH)); + $this->assertEquals($empty, $results->fetch_all(ResultSet::FETCH_NUM)); + $this->assertEquals($empty, $results->fetch_all(ResultSet::FETCH_ASSOC)); + $this->assertEquals($empty, $results->fetch_all(ResultSet::FETCH_BOTH)); } - public function testFetchAll() + public function testfetch_all() { $results = new ResultSet(self::$columns, self::$entries); - $this->assertEquals(self::$entries, $results->fetchAll(ResultSet::FETCH_NUM)); + $this->assertEquals(self::$entries, $results->fetch_all(ResultSet::FETCH_NUM)); - $assocResult = $results->fetchAll(ResultSet::FETCH_ASSOC); + $assocResult = $results->fetch_all(ResultSet::FETCH_ASSOC); foreach ($assocResult as $entry) { $this->assertEquals(array_combine(self::$columns, $entry), $entry); } - $bothResult = $results->fetchAll(ResultSet::FETCH_BOTH); + $bothResult = $results->fetch_all(ResultSet::FETCH_BOTH); foreach ($assocResult as $entry) { $this->assertEquals(array_merge($entry, array_combine(self::$columns, $entry)), $entry); } @@ -53,7 +53,7 @@ public function testFetchAssoc() $results = new ResultSet(self::$columns, self::$entries); $i = 0; - while (($row = $results->fetchAssoc()) !== null) { + while (($row = $results->fetch_assoc()) !== null) { $this->assertEquals(array_combine(self::$columns, self::$entries[$i++]), $row); } $this->assertEquals(count(self::$entries), $i); @@ -64,7 +64,7 @@ public function testFetchRow() $results = new ResultSet(self::$columns, self::$entries); $i = 0; - while (($row = $results->fetchRow()) !== null) { + while (($row = $results->fetch_row()) !== null) { $this->assertEquals(self::$entries[$i++], $row); } $this->assertEquals(count(self::$entries), $i); @@ -75,7 +75,7 @@ public function testFetchBoth() $results = new ResultSet(self::$columns, self::$entries); $i = 0; - while (($row = $results->fetchBoth()) !== null) { + while (($row = $results->fetch_both()) !== null) { $entry = self::$entries[$i++]; $this->assertEquals(array_merge($entry, array_combine(self::$columns, $entry)), $row); } @@ -105,7 +105,7 @@ public function testFetchObject() $results = new ResultSet(self::$columns, self::$entries); $i = 0; - while (($row = $results->fetchObject()) !== null) { + while (($row = $results->fetch_object()) !== null) { $this->assertEquals((object) array_combine(self::$columns, self::$entries[$i++]), $row); } $this->assertEquals(count(self::$entries), $i); @@ -115,34 +115,34 @@ public function testDataSeekBad() { $results = new ResultSet(self::$columns, self::$entries); - $this->assertFalse($results->dataSeek(-1)); - $this->assertFalse($results->dataSeek(count(self::$entries))); + $this->assertFalse($results->data_seek(-1)); + $this->assertFalse($results->data_seek(count(self::$entries))); } public function testDataSeek() { $results = new ResultSet(self::$columns, self::$entries); - $success = $results->dataSeek(7); + $success = $results->data_seek(7); $this->assertTrue($success !== null); - $row = $results->fetchRow(); + $row = $results->fetch_row(); $this->assertEquals(self::$entries[7], $row); } public function testNumRows() { $emptySet = new ResultSet(self::$columns, array()); - $this->assertEquals(0, $emptySet->numRows()); + $this->assertEquals(0, $emptySet->num_rows()); $set = new ResultSet(self::$columns, self::$entries); - $this->assertEquals(count(self::$entries), $set->numRows()); + $this->assertEquals(count(self::$entries), $set->num_rows()); } public function testNumFields() { $set = new ResultSet(self::$columns, self::$entries); - $this->assertEquals(count(self::$columns), $set->numFields()); + $this->assertEquals(count(self::$columns), $set->field_count()); } public function testFetchField() @@ -150,7 +150,7 @@ public function testFetchField() $results = new ResultSet(self::$columns, self::$entries); $i = 0; - while (($field = $results->fetchField()) !== false) { + while (($field = $results->fetch_field()) !== false) { $this->assertTrue(is_object($field)); $this->assertEquals(self::$columns[$i++], $field->name); } @@ -161,18 +161,18 @@ public function testFieldSeekBad() { $results = new ResultSet(self::$columns, self::$entries); - $this->assertFalse($results->fieldSeek(-1)); - $this->assertFalse($results->fieldSeek(count(self::$columns))); + $this->assertFalse($results->field_seek(-1)); + $this->assertFalse($results->field_seek(count(self::$columns))); } public function testFieldSeek() { $results = new ResultSet(self::$columns, self::$entries); - $success = $results->fieldSeek(2); + $success = $results->field_seek(2); $this->assertTrue($success !== false); - $field = $results->fetchField(); + $field = $results->fetch_field(); $this->assertEquals(self::$columns[2], $field->name); } } diff --git a/tests/StatementTest.php b/tests/StatementTest.php index 9ba71d7..ffcd9bf 100644 --- a/tests/StatementTest.php +++ b/tests/StatementTest.php @@ -438,7 +438,7 @@ public function testDataSeek() $expected = ['stephen', 'king', 'derry']; $result = $statement->get_result(); $this->assertTrue($passed === true); - $this->assertEquals($expected, $result->fetchRow()); + $this->assertEquals($expected, $result->fetch_row()); } public function testClose()