Date: 10/29/99
- Next message: Jack Lauman: "Re: [PHPLIB] index.php3 test page error..."
- Previous message: Kristian Köhntopp: "Re: [PHPLIB] preauth problem.."
- Next in thread: Kristian Koehntopp: "Re: [PHPLIB] Function nextid() with PostgreSql"
- Reply: Kristian Koehntopp: "Re: [PHPLIB] Function nextid() with PostgreSql"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello,
I'm using Phplib and PostgreSql. In my program i need a unique number to
insert into a database. But the function nextid() is only define in db_oracle
and db_mysql. I've made a small function which can do this feature. I don't
know if this the 'best' solution but it work. I just include this little code
into the class.
function nextid($seq_name)
{
$this->connect();
$q_id= <email protected>($this->Link_ID,"select nextval('$seq_name')");
if (!$q_id)
{
if (! <email protected>($this->Link_ID,"create sequence $seq_name"))
{
$this->halt("<BR> nextid() function - unable to create sequence");
return 0;
}
$q_id= <email protected>($this->Link_ID,"select nextval('$seq_name')");
if (!$q_id)
{
$this->halt("<BR>pg_exec() failed:<BR>nextID function");
return 0;
}
}
$r= <email protected>($q_id, 0);
if ($r==false)
$nextid=0;
else
$nextid=$r[0];
return $nextid;
}
Voila,
So for my bad english.
-- ,-----------------------------------------------------------------------------. > Saillard Luc | Ingénieur Informatique Libre < > Luc.Saillard <email protected> | Alcôve libère votre informatique.... < > (www.alcove.fr) | < `-----------------------------------------------------------------------------' - PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>. To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in the body, not the subject, of your message.
- Next message: Jack Lauman: "Re: [PHPLIB] index.php3 test page error..."
- Previous message: Kristian Köhntopp: "Re: [PHPLIB] preauth problem.."
- Next in thread: Kristian Koehntopp: "Re: [PHPLIB] Function nextid() with PostgreSql"
- Reply: Kristian Koehntopp: "Re: [PHPLIB] Function nextid() with PostgreSql"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

