Hello im trying out PDO and im stucked in a weird situation.
$statement->fetch()
returns me the desired results, but when i try to fetch em , while doesnt seem to work. I tried use $statement->fetchAll()
with foreach
but it doesnt work either.
I also tried fetch(PDO::FETCH_ASSOC)
but again no luck. AM i doing something wrong ?
$pdoObject = new PDO("mysql:host=$dbhost;dbname=$dbname;", $dbuser, $dbpass);
$pdoObject -> exec("set names utf8");
$sql="SELECT * from prokiriksi_clean where name=:name";
$statement = $pdoObject->prepare($sql);
$statement->execute(array(':name' =>$clean));
$testyo=$statement->fetch();
var_dump($testyo); //returns array
if ($statement->fetch()){
echo 'inside if'; //it is printed
while ($record = $statement->fetch()) {
var_dump($record); //doesnt print
echo 'inside while'; //doesnt print
}
}