On 2002-11-01 04:51, Andi Gutmans wrote: > On Fri, 11 Jan 2002, Markus Fischer wrote: > > What other way do we have to specify arbitray optional > > parameters without an ordering? Teh disadvantage of optional > > parmeters is when you need to only set the last one, you'll > > have to define all preceding optional parameters too. > > How does the MySQL C API handle this? The function that connects to MySQL accepts *many* arguments. :)
Also, a separate function allows options to be set for a connection before it is made. The general process is: /* Get a connection handle */ connection_handle = mysql_init (); /* Set options */ mysql_options (connection_handle, flag, arg_for_flag); /* Now connect to MySQL */ mysql_real_connect ( connection_handle, host, user, password, db_name, port, socket, flags ); I am digging through the MySQL extension to try and figure out how to implement mysql_options without having to do it like the C api. Needless to say, I am learning more C than I ever planned to, :) > I think using array() is pretty sucky. Look at the following example and > I'm sure you're planning on it getting much worse. > mysql_connect("foo", array("bar" => 1, "hello" => 2)); I don't think it is *that* terrible. It seems better than having a billion args to a function - :). I suppose that people can always write wrappers for this sort of case though. PEAR handles this well. IMHO :) > > For functions like mysql_connect() the performance impact is > > negligible (methinks). > > I don't think it'll always be negligible. > It might not always be a bad idea but I think that if we support this > easy to use function we're going to see this kind of stuff pop-up in more > places than the very few places which just can't do without. You are right, that could get nasty. If PEAR becomes more tightly integrated with PHP proper, then we really would not need to worry about this. If someone wants easy, they use the PEAR DB class. If they want fast (or verbose ;) then they can use the extension. -- Zak Greant PHP Quality Assurance Team http://qa.php.net/ "We must be the change we wish to see." - M. K. Ghandi -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]