always do your query preparation outside of your loop.
$p = $datasource->prepare(‘INSERT a SET b = :c’);
amount of memory and time is consumed parsing the query every
iteration. For a million inserts, this can result in
exceeding allowed memory usage.