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

</body>
</html>