Skip to content

Commit f807240

Browse files
committed
rework bug fix, debug call working correctly with prepareOn
In reference to #153
1 parent 25001d9 commit f807240

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

lib/Database/ez_mysqli.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,26 +212,29 @@ private function fetch_prepared_result(&$stmt, $query)
212212
$this->_affectedRows = $stmt->num_rows;
213213
$meta = $stmt->result_metadata();
214214

215+
$x = 0;
215216
// Take note of column info
216217
while($field = $meta->fetch_field()) {
217-
$variables[] = &$col_info[$field->name];
218+
$col_info[$field->name] = "";
219+
$variables[$field->name] = &$col_info[$field->name];
220+
$this->col_info[$x] = $field;
221+
$x++;
218222
}
219223

220224
// Binds variables to a prepared statement for result storage
221225
\call_user_func_array([$stmt, 'bind_result'], $variables);
222226

223-
$x = 0;
224227
$i = 0;
225228
// Store Query Results
226229
while($stmt->fetch()) {
227-
// Store results as an objects within main array
228-
foreach($col_info[$x] as $key => $value) {
229-
$this->last_result[$i] = (object) array( $key => $value );
230-
$i++;
230+
// Store results as an objects within main array
231+
$resultObject = new \stdClass();
232+
foreach($variables as $key => $value) {
233+
$resultObject->$key = $value;
231234
}
232-
$x++;
235+
$this->last_result[$i] = $resultObject;
236+
$i++;
233237
}
234-
$this->col_info = $col_info;
235238
}
236239

237240
// If there is an error then take note of it..

tests/ezsqlModelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function testFlush()
105105

106106
$this->assertNull($this->object->getLast_Result());
107107
$this->assertNull($this->object->getLast_Query());
108-
$this->assertIsArray($this->object->getCol_Info());
108+
$this->assertEquals([], $this->object->getCol_Info());
109109
$this->assertFalse($this->object->getFrom_Disk_Cache());
110110
} // testFlush
111111

0 commit comments

Comments
 (0)