|All requests||>||connect to pdo and display results of...||>||Request new recommendation||>||Featured requests||>||No recommendations|
by Debbie Schmidt - 5 years ago (2015-10-20)
I'm trying to move to PDO and would like a way to do this. to make a connection to a mysql db, execute queries and then display the results of the query in table or list, or array.
I was torn between an older package that allows you to return the object as an array or a newer package that is still being maintained but deals with objects as PDO was meant to. I think if you are going to be working with PDO, then you should probably start thinking in terms of objects instead of arrays, so I went with the newer class as a recommendation.
1. by Pierre Delporte Reply- 5 years ago (2015-10-20)
Thanks Dave for the recommendation. @Debbie, if you need support, let me know, and I will be pleased to try to help you.
2. by Debbie Schmidt - 5 years ago (2015-10-20) Reply
Thank you both for your help. I'll take a look and holler if I get stuck. I'm doing this between jobs (and life) and trying to learn this piecemeal is difficult. It's good to know there's a resource available!
3. by Debbie Schmidt - 5 years ago (2015-10-22) in reply to comment 1 by Pierre Delporte Reply
Hi Pierre, Thanks for your offer of help. I find I am getting an error:
SQLSTATE[HY000]  Access denied for user 'root'@'localhost' (using password: YES)' in R:\wamp\www\test\full-db-pdo-abstract-2015-10-02\DB.php on line 140.
I've looked at line 140:
$this->oPdo = new PDO('mysql:dbname=' . $this->db . ';host=' . $this->host . ';', $this->user, $this->pass, array(PDO::ATTR_PERSISTENT=> true));
But it seems to be ok. I've researched the error and made sure that localhost has all privileges. Not sure where to look next... Any help would be appreciated.
Let me know if you want me to use email or your support forum page. Not sure what etiquette is for this. Thanks!
4. by Pierre Delporte Reply- 5 years ago (2015-10-23) in reply to comment 3 by Debbie Schmidt
I think that the error that you received is because you did not supply any password. Could you please show us the way you are initializing the connection ?
It should be something like : $dblink = DB::getInstance(HOST, USER, PASSWORD, DBNAME, TYPEDB);
where HOST, USER, PASSWORD, DBNAME and TYPEDB are all defined constants :
define ('HOST', 'localhost'); define ('USER', 'root'); define ('PASSWORD', 'mypassword'); define ('DBNAME', 'mydb'); define('TYPEDB', 'mysql');
Hope it helps.
5. by Pierre Delporte Reply- 5 years ago (2015-10-23) in reply to comment 3 by Debbie Schmidt
Debbie, my email is in the example file ;)