2017-05-03 23:33:19 +02:00
|
|
|
--TEST--
|
|
|
|
Test the fetchColumn() method.
|
|
|
|
--SKIPIF--
|
2017-11-02 01:09:58 +01:00
|
|
|
<?php require('skipif_mid-refactor.inc'); ?>
|
2017-05-03 23:33:19 +02:00
|
|
|
--FILE--
|
|
|
|
<?php
|
2017-11-02 01:09:58 +01:00
|
|
|
require_once("MsCommon_mid-refactor.inc");
|
|
|
|
require_once("MsData_PDO_AllTypes.inc");
|
|
|
|
|
|
|
|
try {
|
|
|
|
$db = connect();
|
|
|
|
$tbname = "PDO_MainTypes";
|
|
|
|
createAndInsertTableMainTypes($db, $tbname);
|
|
|
|
|
|
|
|
$stmt = $db->query("Select * from $tbname");
|
|
|
|
|
2017-11-04 01:01:09 +01:00
|
|
|
// Fetch the first column from the next row in resultset. (This would be first row since this is a first call to fetchcol)
|
2017-11-02 01:09:58 +01:00
|
|
|
$result = $stmt->fetchColumn();
|
|
|
|
var_dump($result);
|
2017-05-03 23:33:19 +02:00
|
|
|
|
2017-11-02 01:09:58 +01:00
|
|
|
// Fetch the second column from the next row. (This would be second row since this is a second call to fetchcol).
|
|
|
|
$result = $stmt->fetchColumn(1);
|
|
|
|
var_dump($result);
|
2017-05-03 23:33:19 +02:00
|
|
|
|
2017-11-02 01:09:58 +01:00
|
|
|
// Test false is returned when there are no more rows.
|
|
|
|
$result = $stmt->fetchColumn(1);
|
|
|
|
var_dump($result);
|
|
|
|
|
|
|
|
dropTable($db, $tbname);
|
|
|
|
unset($stmt);
|
|
|
|
unset($conn);
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
var_dump($e);
|
2017-05-03 23:33:19 +02:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-02 01:09:58 +01:00
|
|
|
?>
|
2017-05-03 23:33:19 +02:00
|
|
|
--EXPECT--
|
|
|
|
string(1) "1"
|
|
|
|
string(10) "STRINGCOL2"
|
|
|
|
bool(false)
|