Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP';s PDO SQLite驱动程序正在返回重复的日期_Php_Sqlite - Fatal编程技术网

PHP';s PDO SQLite驱动程序正在返回重复的日期

PHP';s PDO SQLite驱动程序正在返回重复的日期,php,sqlite,Php,Sqlite,我正在服务器上运行PHP5.4.4,使用/configure编译。我有一个带有SQLite 3.7.7.1驱动程序的PDO。我已经创建了以下表格 CREATE TABLE IF NOT EXISTS login ( id PRIMARY KEY ON CONFLICT REPLACE, given_name, family_name, gender ); CREATE TABLE IF NOT EXISTS address ( id, street

我正在服务器上运行PHP5.4.4,使用
/configure
编译。我有一个带有SQLite 3.7.7.1驱动程序的PDO。我已经创建了以下表格

CREATE TABLE IF NOT EXISTS
login (
    id PRIMARY KEY ON CONFLICT REPLACE,
    given_name,
    family_name,
    gender
);
CREATE TABLE IF NOT EXISTS
address (
    id,
    street,
    city,
    state,
    zip,
    FOREIGN KEY(id) REFERENCES login(id) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS
certification (
    id,
    certification,
    certification_expiration,
    FOREIGN KEY(id) REFERENCES login(id) ON DELETE CASCADE
);
而这一观点

CREATE VIEW "members" AS SELECT
    login.id, login.given_name, login.family_name, login.gender,
    address.street, address.city, address.state, address.zip,
    certification.certification, certification.certification_expiration
FROM
    login, address, certification
WHERE
    login.id = certification.id
    AND
    login.id = address.id
我正在查询如下视图:

<?php   foreach ($sql->query('SELECT * FROM members;') as $row):    ?>
                    <tr>
<?php       foreach ($row as $index => $col): ?>
                        <td><?=$index;?>.<?=$col;?></td>
<?php       endforeach; ?>
                    </tr>
<?php   endforeach; ?>

.
它正在产生这样的输出

            <tr>
                <td>id.123456789012345678901</td>
                <td>0.123456789012345678901</td>
                <td>given_name.Mark</td>
                <td>1.Mark</td>
                <td>family_name.Tomlin</td>
                <td>2.Tomlin</td>
                <td>gender.Male</td>
                <td>3.Male</td>
                <td>street.1 Some Lane</td>
                <td>4.1 Some Lane</td>
                <td>city.Anywhere</td>
                <td>5.Anywhere</td>
                <td>state.NY</td>
                <td>6.NY</td>
                <td>zip.12345</td>
                <td>7.12345</td>
                <td>certification.AEMT-P</td>
                <td>8.AEMT-P</td>
                <td>certification_expiration.2015-07-31</td>
                <td>9.2015-07-31</td>
            </tr>

id.1234567890012345678901
0.123456789012345678901
马克
1.马克
姓汤姆林
2.汤姆林
性别:男
3.男性
一条街,一条小巷
4.1一些车道
城市,任何地方
5.任何地方
纽约州
纽约州
邮编:12345
7.12345
认证编号:AEMT-P
8.AEMT-P
认证日期:2015年7月31日
9.2015-07-31
我想知道,为什么它会给我
id.
0.
,以及
给我的名字。
1.
,我能做些什么从查询中过滤出这种行为?我只想得到
id.
0.
,但不是两种类型。

这就解决了它

$sql->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
帽子提示,用于帮助。

您可以从这里开始:
PDO::FETCH_BOTH(默认值):返回一个数组,该数组按结果集中返回的列名和0索引列号进行索引。