473,770 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2313
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
14159
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 same time get the value that the serial column just got incremented to. I'm using PHP for my API, and pg_query() doesn't return anything on an insert. pg_insert() just returns a bool. I've done similar things in MS SQL server with stored...
1
838
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 to completion. Version 4 seems to STOP when it encounters a duplicate entry, so that the records before the duplicate are inserted and the records after the duplicate are not inserted. 3.22.27.1 - previous ver MySQL that did not return error...
6
7016
by: Mark P | last post by:
Some time ago I posted here about inserting into a set with a hint: http://groups-beta.google.com/group/alt.comp.lang.learn.c-c++/browse_thread/thread/fb75b00f73e979db/018b8d0eadb38dbf?q=%22STL+insert+with+hint%22+%22Mark+P%22&rnum=1&hl=en#018b8d0eadb38dbf I quoted the SGI STL docs describing a.insert(p, t), where p is the hint iterator and t is the inserted object: "Insert with hint is logarithmic in general, but it is amortized...
2
1621
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 can use something like this...but I want it to be one line (I'm using ADO). select carid from table2 where field=x into var; insert into users (homeid,carid) values(1,var); Any ideas?
4
5486
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 this would be happening, we would appreciate feedback. We have tested on 7.3.4, 7.3.6 and 7.4.1 and all exhibit the same behavior. Test case one tries to populate table2 from table1 with records that are not in table2 already. Table2 gets...
7
19315
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 WHERE idsection = 'CZE'), 'CZE', 'sample text') ); This works fine, except when the result of SELECT is empty - which is
6
2361
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 parameters. It returns my error text message in another output parameter as "ok", which is the value that is set in the stored procedure prior to doing the insert. It returns my var for @@rowcount as 1. However, the record does not get into the table. ...
1
2053
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: NF000001.D8B5.061208085417". Can anyone help?Thanks
0
3015
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 accounting ctr is the last three letters of the text file being used for the BULK INSERT. How would you suggest that I do this? Is there a way to add a default value to the .fmt or schema files for the text fields, or in the BULK INSERT...
6
9040
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 inserting duplicate keys to the multiset i need output order to be in insert order.
0
9591
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9869
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7415
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.