Pavel Tashev
Pavel Tashev / Entrepreneur and Software Developer
Constantly learning new things. I love to be part of projects and StartUps that inspire me and improve the life of society.
Contact me via LinkedIn
Isle of Man, UK and Bulgaria
Doctrine 1.x Madness

Doctrine 1.x Madness Database


A couple of months ago I met an issue with Doctrine 1.x which completely smashed my brain and it seems to be a bug issue! If you use WhereIn() and pass an empty array as a second parameter the condition will be always “true”. Take a look at the next code:

$ids = array();
$q = Doctrine_Core::getTable('VeryImportantTable')
              ->whereIn('', $ids)

It turns out that when we pass an empty array, Doctrine 1.x thinks about it as “all records in table VeryImportantTable” and in the spirit of the above example that means “delete all records from table VeryImportantTable”. That seams to be a huge bug issue because if we miss to check the content of the array we may accidentally delete very important information from our database. A simple workaround might be:

  //than delete

// or

  //than delete

Be on the lookout for this kind of problems! Special thanks to my partner Lyubomir Slavilov.

Share me please:

1 Comment

  1. Williampiow
    June 20, 2016 at 3:26 am · Reply

    I am so grateful for your forum.Much thanks again. Awesome. Wirght

Leave a Reply

fourteen + eighteen =


Please type the text above: