Hello! Been looking for the solution for a week. I’m new in oop and pdo. In my update form, I just want to show in the textbox the value ready, every time I edit a data.

I’m using this tuts

Help me out of this please. tnx.

What exactly is the problem?

My problem is how to make function that will show value from my db. I made this thing and I’m not sure about it.

public function viewItem(){
$sql = “SELECT * FROM dbo.guitar WHERE id=:id”;

	$q = self::$db->prepare($sql);
	$row = $q->rowCount();
	$results = $q->fetchAll(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE,
            array('id', 'make', 'model', 'colour', 'price'));
	catch (Exception $e){
    print "Error!: " . $e->getMessage();

Well for starters, your execute doesnt declare what the value of :id should be…

From your post it seems you are teaching yourself OOP and PDO simultaneously, but it seems to me you have not grasped the PDO basics.

I really don’t think this is a good strategy, there is just far too much that can go wrong and for anyone here to provide any meaningful assistance – you will end up posting reams of code which will itself put others off helping you.

Please don’t take this the wrong way, but I am sure it would help if you just back up a little bit and take on PDO on its own (which already a handful).

I know that PDO is an OOP class, but using an object is far easier to learn than creating classes.

Assuming your SQL skills are good, what you need to do is spend a day or so looking at PDOs documentation and working through some examples using PDO as userland code rather than trying to encapsulate it in other Classes. (ie you set up your connection, and call a new PDO(), then iterate through some results sets, arrays, objects, single rows and so on as PHP code).

[google]PDO tutorials[/google]

Wez Furlongs original PHP Data Objects slides were my kicking off point, and might provide a useful birds eye view.

Once you have established for yourself some working examples of each of the options available to PDO, and have understood its relationship to the entirely different PDOStatement class, you will be ready to roll with that CRUD tutorial.

Good luck with it, and if you have questions, then do come back and ask.