ID:          47331
 Comment by:  ryanrray at gmail dot com
 Reported By: daevid at daevid dot com
 Status:      Open
 Bug Type:    Feature/Change Request
 PHP Version: 5.2.9RC1
 New Comment:

You should be able to call out any param explicitly.


Previous Comments:
------------------------------------------------------------------------

[2009-02-06 20:22:17] daevid at daevid dot com

Description:
------------
Request a way to use the default values of a function without
specifying every single one until the parameter you want to modify.

The concept is simple, just specify which parameters in the function
call you want to change and leave the others as their default.

So given a function that takes seven parameters, I want to change one
(or more) of them and leave the other defaults alone without
specifically re-defaulting each value (which assumes I even know what
each default value is to begin with)

Bug #2285 is similar, but passing an array is a hack and not
acceptable. It will not help in an IDE setting to see foo(array) and not
know which key/values the hash expects.

Bug #20544 is also close, but I don't agree with using "->" or "=>"
either. it should just be "=" as illustrated below.

Bug #24153 is also similar, but using "," as place holders seems a
little hacky too and difficult to read. Plus who wants to count empty
place holders to figure out which parameter is being set?

Reproduce code:
---------------
function SQL_QUERY($sql, $parameters = null, $showSQL = false,
$showErrors = true, $execute = true, $noHTML = false, $profile = 0)
{
        var_dump($sql, $parameters, $showSQL, $showErrors, $execute,
$noHTML, $profile);
}

SQL_QUERY('SELECT * FROM foo WHERE bar = ?', array('beep'),
$execute=false);

The above function call doesn't error out on me, it just seems it
doesn't do anything either :-\

Expected result:
----------------
string(31) "SELECT * FROM foo WHERE bar = ?"
array(1) {  [0]=>  string(4) "beep" }
bool(false)
bool(true)
bool(true)  <-- I would have expected this one to be bool(false)
bool(false)
int(0)

Actual result:
--------------
So it seems I have to do this verboseness (AND know what the default
values are to begin with too):

SQL_QUERY('SELECT * FROM foo WHERE bar = ?', array('beep'), false,
true,
false, false);

Just to change one default parameter near the end?!? :-(

-------------------------------

P.S. this PHP bug report form made me choose a PHP version to submit
this, even though I picked "irrelevant" I had to then choose 5.2.9rc1
just to submit :-\


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47331&edit=1

Reply via email to