MAX on a query.
| From: | ThE PhP_KiD | Date: | Wed, 04 Jun 2003 17:26:09 +0000 |
| Subject: | MAX on a query. | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-5796@lists.php.net to get a copy of this message | ||
Hi
There is a way to make a "SELECT MAX(id) FROM Lotes"
with DataObjects ?
At the momment I'm getting last result with DB:
<?php
require_once('DB.php');
// get DSN from DataObjects config File.
$options=parse_ini_file($_SERVER['DOCUMENT_ROOT']."/classes/jalilstamps.ini"
);
$dsn=$options['database'];
$db = DB::connect($dsn);
if (DB::isError($db)) {
die ($db->getMessage());
}
$sql = "SELECT MAX(id) FROM Lotes";
$result = $db->query($sql);
$db->disconnect();
$last_id=$result->fetchRow();
$new_id=$ultimo_id[0] + 1;
?>
Thank you !
Regards
mac
--
...ThE PhP_KiD.