[Solar-talk] bounding zero

Rodrigo Moraes rodrigo.moraes at gmail.com
Sun Mar 11 21:53:02 PDT 2007


Hi.
I'm in doubt about the cleanest way to bound a variable that can be 0
(integer zero). For example:

    $select = Solar::factory('Solar_Sql_Select');
    $res = $select->from('my_table', 'my_column')
        ->where('my_column = ?', $x)
        ->fetch('value');

If $x = 0, a exception is thrown, but if $x = '0' it is not. Is it
really necessary to quote the zero or cast it to a string? I thought
this could be a bug in Solar_Sql_Select::where(), on these lines:

    if ($val != SOLAR_IGNORE_PARAM) {
        $cond = $this->_sql->quoteInto($cond, $val);
    }

0 (integer) won't pass this condition for some reason that I couldn't
understand, but '0' (string) will. Is this the expected behaviour?
What would be clean and uniform when you don't know the value of $x?

thanks,
rodrigo
-------------------------------
http://tipos.com.br


More information about the solar-talk mailing list