Jump to content
Killersites Forums

PDO no longer found when using namespaces


Recommended Posts



Now that I'm implementing namespaces, PDO is no longer being found. I'm doing:


$this->db = new PDO('mysql:dbname=db;host=localhost', 'root', '');


It's trying to find application\path\PDO.php which is not the case. I tried doing:


$this->db = new \PDO('mysql:dbname=db;host=localhost', 'root', '');


but that didn't work. The current namespace I'm using is:


use \application\database as Mapper;


Then I did:


$this->db = new Mapper\PDO('mysql:dbname=db;host=localhost', 'root', '');


But that was no good either. It keeps looking for a physical file PDO.php. Not sure where I'm going wrong?

Link to comment
Share on other sites

  • 2 months later...

Hi This might help you.

$db = new PDO('mysql:host=localhost;dbname=<SOMEDB>', '<USERNAME>', 'PASSWORD');
$stmt = $db->prepare("select contenttype, imagedata from images where id=?");
$stmt->bindColumn(1, $type, PDO::PARAM_STR, 256);
$stmt->bindColumn(2, $lob, PDO::PARAM_LOB);
header("Content-Type: $type");
echo $lob; // fpassthru reports an error that $lob is not a stream so echo is used in place.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...