For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2004 > mysql connectivity...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author mysql connectivity...
Michael Gargiullo

2004-10-27, 8:55 pm

I have a table like so:

id -> auto increment
name -> name

After I insert a new name
insert into mytable values('','Bob');

I need Bob's id returned.



Chris Devers

2004-10-27, 8:55 pm

On Wed, 27 Oct 2004, Michael Gargiullo wrote:

> I have a table like so:
>
> id -> auto increment
> name -> name
>
> After I insert a new name
> insert into mytable values('','Bob');
>
> I need Bob's id returned.


Hey, wait -- you could write a program to do that, couldn't you!

And reading `perldoc DBD::mysql` would totally show you how!

(Hint -- search in the perldoc for 'insertid'.)


--
Chris Devers
Michael Gargiullo

2004-10-27, 8:55 pm

On Wed, 2004-10-27 at 15:42, Chris Devers wrote:
> On Wed, 27 Oct 2004, Michael Gargiullo wrote:
>
>
> Hey, wait -- you could write a program to do that, couldn't you!
>
> And reading `perldoc DBD::mysql` would totally show you how!
>
> (Hint -- search in the perldoc for 'insertid'.)
>


Thanks Chris,

I was using the PHP function instead of perl's...

Chris Devers

2004-10-27, 8:55 pm

On Wed, 27 Oct 2004, Michael Gargiullo wrote:

> On Wed, 2004-10-27 at 15:42, Chris Devers wrote:
>
> Thanks Chris,
>
> I was using the PHP function instead of perl's...


You did look it up, right?

I deliberately gave only part of the string you need to use...


--
Chris Devers
Michael Gargiullo

2004-10-27, 8:55 pm

On Wed, 2004-10-27 at 16:16, Chris Devers wrote:
> On Wed, 27 Oct 2004, Michael Gargiullo wrote:
>
>
> You did look it up, right?
>
> I deliberately gave only part of the string you need to use...
>


Yup... $id=$dbh->{'mysql_insertid'}; Worked like a charm.

Chris Devers

2004-10-27, 8:55 pm

On Wed, 27 Oct 2004, Michael Gargiullo wrote:

> On Wed, 2004-10-27 at 16:16, Chris Devers wrote:
>
> Yup... $id=$dbh->{'mysql_insertid'}; Worked like a charm.


Good -- now you know how to find future answers :-)



--
Chris Devers
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com