That's the first time i get an error like this one, let me explain :
Here is my code :
function printSiteIndexedItems($co, $id){
global $allSections;
foreach($allSections as $aSection => $aSectionName){
$tr = $co->prepare("SELECT COUNT(id) FROM ". $aSection ." WHERE site=:id AND valide=1");
$tr->bindParam(':id', $id, PDO::PARAM_INT);
$tr->execute();
if($indexedItems = $tr->fetchColumn()) echo '<p>'. $aSectionName .' : '. $indexedItems .'</p>';
}
}
The first iteration works just fine, it prints what i want (a category name and the number of elements in it).
But after that first iteration, i get this classic error :
Fatal error: Call to a member function bindParam() on a non-object in
Indeed, $co is a valid PDO object as it works for the first iteration. But it seems that as soon as we enter the second one, it no longer is ? :o
I'm kinda new with PDO, so maybe it's a normal behavior i didn't acknowledge yet. Please help ! =)