Ok.. let’s try something completely different.. I’m going to start writing a few posts in english.. ( or at least try )..

For those who don’t know, I just switched jobs, I’m currently working on a small agency in the middle of Lisbon.. It’s going great so far.. I just made one month..

On the second week of work, I came across this piece of code from our custom CMS:

public function updateCategory( $item )
    $select_ids_q = " SELECT id FROM categories ";
    $ids2compare = Array();
    $select_ids = BdConn::runSQL( $select_ids_q );

    while($row = mysql_fetch_array($select_ids)) {
        $ids2compare[] = $row['id'];
    $new_cat_id = self::genRandId($ids2compare);
    //do insert of category

public function genRandId($numToCompareArr) {
    $new_id = rand();
    for($i = 0; $i < count($numToCompareArr); $i++) {
        if($new_id == $numToCompareArr[$i])
    return $new_id;

This is good code.. don’t you think? I almost had an heart attack on the spot when I saw this.. at that moment I was debugging the code, trying to find out what the code did, everything is in Ajax, with redirects after the Ajax call is completed.. ( which in my opinion is not a good thing for a back office )…

It wasn’t a fun day, the next day I decided to use my own back office to do the site.. then everything started to run smoothly..

No Comment.

Add Your Comment