我在我的服务器上运行PHP 5.4.4,使用./configure
编译。我有PDO与SQLite 3.7.7.1驱动程序。我创建了以下表格。
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.
和0.
,以及given_name.
和1.
,我有什么办法可以过滤这种行为从查询出来?我想只获得id.
或仅0.
,而不是两种类型。
答案 0 :(得分:1)