You'll need a reference to your PDO instance $pdo somewhere.... $stmt = $pdo->prepare($query); $stmt->execute($args); return $stmt->fetchAll(); }.
Works with LIMIT clauses. If you're using simple queries / are not that bothered with type: function fetchAll(){ $args = func_get_args(); $query = array_shift($args);//'SELECT * FROM users WHERE status=? LIMIT?
,? ' //you'll need a reference to your PDO instance $pdo somewhere.... $stmt = $pdo->prepare($query); $stmt->execute($args); return $stmt->fetchAll(); }.
Well I am bothered with type, at least to distinguish ints from strings. But it seems doesn't matter with PDO. Nothing bad if I pass a string for the last 2 placeholders - right?
– Col. Shrapnel Sep 16 '10 at 11:11 Well it doesn't work, throwing an error, near ''0','2''. Looks like default string type doesn't work for LIMIT clause – Col.
Shrapnel Sep 16 '10 at 12:35 Hmm, you're right. I seem to remember that about 2 years ago I could (but haven't since forgone the type), but at this time, LIMIT indeed errors on it with the 'default' string. – Wrikken Sep 16 '10 at 14:20 1 As stereofrog have just pointed out in my other question, its prepared statements emulation option gets responsible for such behavior.By adding $dbh->setAttribute( PDO::ATTR_EMULATE_PREPARES, false ); this error can be eliminated.
– Col. Shrapnel Sep 16 '10 at 15:54 Ah, cheers, explains why I could use them before ;) – Wrikken Sep 16 '10 at 17:01.
Every example I can find shows only how to bind parameters directly. Should I pass variable type as well as it's value? Or make this call always 4 lines - 3 binds and execute?
You don't have to fire binds one line at a time; you can bind with an array like this: # the data we want to insert $data = array('Cathy', '9 Dark and Twisty Road', 'Cardiff'); $STH = $DBH->("INSERT INTO folks (name, addr, city) values (?,? ,? )"); $STH->execute($data).
I was concerned for LIMIT clause. Seems it's impossible to omit type setting in this case... – Col. Shrapnel Sep 16 '10 at 12:36.
Every example I can find shows only how to bind parameters directly. Should I pass variable type as well as it's value?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.