Murray @ PlanetThoughtful wrote:
Hi All,

I'm curious to know what other members of the list think of as the code
snippets they couldn't live without when working on a PHP project. IE, the
kind of re-usable bits and pieces that make your life a lot easier.

For myself, I have an include file in which I define 'shorthand' functions
for functions etc I use on a regular basis.

Eg:

function asl($val){
        return addslashes($val);
}

function mfr(&$rset){
        mysql_free_result($rset);
}

...and so on.

Just thought it would be interesting to see what others do to make
programming more bearable.

Probably the custom one I use the most is for getting data...

function selectData ( $sql ) {
        if ( ! $_SESSION['mysql']['status'] ) {
                dbconn();
        }
        if ( $result = @mysql_query ( $sql ) ) {
                $return = array();
                while ( $row = @mysql_fetch_array ( $result ) ) {
                        array_push ( $return, $row );
                }
                @mysql_free_result ( $result );
                return $return;
        } else {
                $msg = "The query could not be executed.";
                raiseError ( $msg, 0, 1 );
                return false;
        }
}

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to