<html>
<!-- BEGIN WEBMAIL STATIONERY -->
<head></head>
<body>
<!-- WEBMAIL STATIONERY noneset -->
<DIV></DIV>Yes, I did try that, although I'm using mysqli instead of mysql (it works the same way in both versions). It works if I don't use the stored procedure, but it does not work with the stored procedure. If use just a prepared statement with the SQL statement in the actual prepared statement, then I can simply call myslqi_insert_id() and it works just fine. I'm just wondering if the stored procedure is really making it harder or I just don't understand how to call it correctly. It's very hard to find any extensive documentation on these new functions. It takes a while for the comment section on php.net to get populated with good examples of new funtions.<BR>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">-------------- Original message from James Loghry <loghry@krellinst.org>: -------------- <BR><BR><BR>> Not quite sure how it works with stored procedures, but you could try <BR>> using mysql_insert_id() after you call the SP. See: <BR>> http://us3.php.net/manual/en/function.mysql-insert-id.php. <BR>> <BR>> carl-olsen@mchsi.com wrote: <BR>> > I'm wondering if I can do both queries at once, such as "SELECT @article_id <BR>> FROM CALL sp_Create()". <BR>> > <BR>> > Carl <BR>> > <BR>> > -------------- Original message from "Carl Olsen" <CARL-OLSEN@MCHSI.COM>: <BR>> -------------- <BR>> > <BR>> > <BR>> > <BR>> >> I like your attitude. I can't remember when the last user meeting was <BR>> >> scheduled, but this would be a great topic! <BR>> >> <BR>> >> Thank you! <BR>> >> <BR>> >
;> Carl <BR>> >> <BR>> >> -----Original Message----- <BR>> >> From: Tony Bibbs [mailto:tony@tonybibbs.com] <BR>> >> Sent: Tuesday, July 11, 2006 7:15 AM <BR>> >> To: carl-olsen@mchsi.com; ciapug@cialug.org <BR>> >> Subject: Re: [ciapug] Re: Re: MySQL 5 Stored Procedures (correction) <BR>> >> <BR>> >> More than likely, yes, you will need to do two queries. One does the <BR>> >> insert, one to get the last_insert_id. FWIW that ORM I was speaking of, <BR>> >> Propel, would have given you the id: <BR>> >> <BR>> >> // Instantiate some generated Propel Object <BR>> >> $myObj = new SomePropelObject(); <BR>> >> <BR>> >> // Set some data on object <BR>> >> $myObj->setAttribute1($foo); <BR>> >> $myObj->setAttribute2($foo); <BR>> >> <BR>> >> // Now save. Propel can manage if it needs to do an INSERT <BR>> >>
; // or an UPDATE for you. <BR>> >> $myObj->save(); <BR>> >> <BR>> >> // After the save our autogenerated ID will have a value <BR>> >> echo $myObj->getSomePrimaryKey(); <BR>> >> <BR>> >> Writing SP's (and SQL in general) is over-rated. I'd rather on meeting <BR>> >> business requirements and leave the lower level database stuff to the ORM. <BR>> >> <BR>> >> Speaking of which, if it hasn't been done already, I'd be willing to <BR>> >> cover Propel at one of the meetings since I'm yapping about it so much. <BR>> >> <BR>> >> --Tony <BR>> >> <BR>> >> Carl Olsen wrote: <BR>> >> <BR>> >>> I put EVERYTHING possible in my databases, but I never use a third party <BR>> >>> tool to do it. I use the SQL Server Enterprise Manager for SQL Server, <BR>> >>> SQLyog for MySQL, and linux command line for PostgreSQL. I guess
I just <BR>> >>> find this stuff interesting and it works well for what I'm doing. In <BR>> >>> <BR>> >> regard <BR>> >> <BR>> >>> to my original question, I have code for PostgreSQL stored procedures that <BR>> >>> just returns the value of the inserted ID without having to do two <BR>> >>> <BR>> >> queries. <BR>> >> <BR>> >>> That's why I was wondering if I was doing something wrong with MySQL. I <BR>> >>> looks like I have to do two queries to do the same thing I can do with <BR>> >>> PostgreSQL or SQL Server with one query. <BR>> >>> <BR>> >> _______________________________________________ <BR>> >> ciapug mailing list <BR>> >> ciapug@cialug.org <BR>> >> http://cialug.org/mailman/listinfo/ciapug <BR>> >> <BR>> >> -----------------------------------------------------------------------
- <BR>> >> <BR>> >> _______________________________________________ <BR>> >> ciapug mailing list <BR>> >> ciapug@cialug.org <BR>> >> http://cialug.org/mailman/listinfo/ciapug <BR>> >> <BR>> <BR>> <BR>> -- <BR>> James Loghry <BR>> Software Engineer <BR>> The Krell Institute <BR>> 1609 Golden Aspen Dr., Suite 101 <BR>> Ames, IA 50010 <BR>> http://www.krellinst.org <BR>> Phone: (515) 956 - 3696 <BR>> Email: loghry@krellinst.org <BR>> <BR>> _______________________________________________ <BR>> ciapug mailing list <BR>> ciapug@cialug.org <BR>> http://cialug.org/mailman/listinfo/ciapug </BLOCKQUOTE>
<!-- END WEBMAIL STATIONERY -->
</body>
</html>