php - PDO query result includes "PDO Object()" -
i'm new pdo, suspect cause of problem i've overlooked somewhere. what's happening this: when run query on pdo like
$sql = "select * table"; $result = $pdo->query($sql);
$result
looks this:
pdo object() {[field1:value], [field2:value]}
so what's going on? why phrase "pdo object()" @ start of result set? none of examples i've seen show this, , many google searches have been fruitless. help appreciated.
as michael berkowski explained need fetch
. since you're learning utilize prepared statements (more secure). here's how it.
$sql = "select * some_table field = :somevar"; $statement = $pdo->prepare($sql); $statement->execute(array(':somevar'=>"expectedfieldvalue")); $result = $statement->fetchall();
php mysql pdo
No comments:
Post a Comment