Re: How to get values from a getAll / getAssoc - Array ?
| From: | Thomas Schulz | Date: | Tue, 29 Apr 2003 14:55:47 +0000 |
| Subject: | Re: How to get values from a getAll / getAssoc - Array ? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-5126@lists.php.net to get a copy of this message | ||
Ts schrieb in php.pear.general:
> I'm using Smarty-Templates.
> The connection to PostgreSQL works and a get 12 rows from my select.
>
> .....
>
> $db = DB::connect($dsn, TRUE);
Depending on the array you expected by getAssoc() possibly you have to set:
$db->setFetchMode(DB_FETCHMODE_ASSOC);
> $sql = "SELECT pid, name, vorname FROM t_bew_schueler";
>
> $res = $db->query($sql);
>
> $rows = $res->numRows(); // this says, i've 12 Rows to display!
>
> $schueler = $db->getAssoc($query);
$query is not definend. Please adjust your error reporting!
$schueler = $db->getAll($sql);
$rows = count($schueler);
print_r($schueler) is useful to show the array for debugging.
> {foreach item=i from=$schueler}
> <br> {$i.pid}, {$i.vornanme}, {$i.name}
> {/foreach}
This looks correct.
ThS.
--
http://4bconsult.de