我在我的服务器上运行 PHP 5.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.
and 0.
, and given_name.
and 1.
,还有什么我可以从查询中过滤掉这种行为吗?我想得到只是id.
或只是0.
但不是两种类型。