473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Returning the id of an inserted row when using DB_DataObject->insert()with postgresql

Sam
Recently started using DB_DataObject with a Postgresql DB. Seems
pretty nice, but I am not sure if insert() is supposed to be able to
return the id of a recently returned object. It just seems to return 1
for me. I'm not really sure if DataObject gets confused because it
would like to create the sequences itself which have been created for
me automatically because I created the primary keys as serials. Or
something like that. Would at least like to hear if it's supposed to
work so I know if it's my fault that it's not working.
Nov 19 '07 #1
2 2285
On Mon, 19 Nov 2007 19:48:18 +0100, Sam <sg******@gmail.comwrote:
Recently started using DB_DataObject with a Postgresql DB. Seems
pretty nice, but I am not sure if insert() is supposed to be able to
return the id of a recently returned object. It just seems to return 1
for me. I'm not really sure if DataObject gets confused because it
would like to create the sequences itself which have been created for
me automatically because I created the primary keys as serials. Or
something like that. Would at least like to hear if it's supposed to
work so I know if it's my fault that it's not working.
http://pear.php.net/manual/en/packag...ect.insert.php
http://pear.php.net/manual/en/packag...-sequences.php
--
Rik Wasmus
Nov 19 '07 #2
Sam
Here's how I understand the situation right now:
Non-MySQL DBs use DB's nextId() and createSequence(). The sequence
info for DB says that you should only use these methods to access the
sequences, including for creation. I had used serials as data type for
my ids however, which results in a sequence automatically being
created by the DB. So I thought this could have caused some confusion.
So I removed the default value for the id in the table and got rid of
the sequence it was using as well. Now insert fails completely because
it tries to insert a NULL value into the id column. So it seems that
DB_DataObject doesn't manage to get an id at all right now.
Anyone have this working?
Nov 22 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: t_pet422 | last post by:
Hi, I've got a table in PostgreSql 7.3.2 that has a serial column as a primary key. I want to insert data into the table (inserting values for everything EXCEPT the serial column) and at the...
1
by: Gary Lundquest | last post by:
It appears to me that MySQL version 4 returns an error messge when doing an Insert that results in duplicate entries. Version 3 did NOT return an error - it dropped the duplicate entries and ran...
6
by: Mark P | last post by:
Some time ago I posted here about inserting into a set with a hint: ...
2
by: Bruce D | last post by:
In theory this is what I would like to do...but I get an error: insert into users (homeid,carid) values(1, select carid from table2 where field=x); Since this doesn't work...I was wondering if I...
4
by: Chris Kratz | last post by:
Hello all, We have run into what appears to be a problem with rules and subselects in postgres 7.4.1. We have boiled it down to the following test case. If anyone has any thoughts as to why...
7
by: Milos Prudek | last post by:
I need to insert a value = max(value)+1, where max is a select limited by a 'where' clause. Like this: INSERT INTO table (idthread, idsection,txt) VALUES ( (SELECT max(idthread)+1 FROM table...
6
by: SandySears | last post by:
I am trying to use a stored procedure to insert a record using VS 2005, VB and SQL Server Express. The code runs without errors or exceptions, and returns the new identifer in the output...
1
by: siujean | last post by:
Hi All, I met a problem when insert over 1000 records to db2 via servlet, it show me the error message is "DB2 SQL error: SQLCODE: -911, SQLSTATE: 40001, SQLERRMC: 68 DB2ConnectionCorrelator:...
0
by: ozkhillscovington | last post by:
We have sp's in place that do BULK INSERTS from txt files into the tables. This works fine, however they have asked us to add a field that identifies accounting ctr. The only thing that identifies...
6
by: reppisch | last post by:
Hi Ng, I have a multiset for keeping elements sorted in a container but key values may also be equal. Is there any guaranteed traversal order within the duplicate keys of a multimap? When...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.