# Access FaaPz/Slim-PDO from container in model

**URL:** <https://discourse.slimframework.com/t/access-faapz-slim-pdo-from-container-in-model/1175>\
**Category:** Questions\
**Created:** [February 23, 2017, 12:04pm UTC](https://discourse.slimframework.com/t/access-faapz-slim-pdo-from-container-in-model/1175 "2017-02-23T12:04:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rakma](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@rakma](https://discourse.slimframework.com/u/rakma)\
**Post date:** [February 23, 2017, 12:04pm UTC](https://discourse.slimframework.com/t/access-faapz-slim-pdo-from-container-in-model/1175/1 "2017-02-23T12:04:24Z")

</div>

IM trying to access PDO ([https://packagist.org/packages/slim/pdo](https://packagist.org/packages/slim/pdo)) from the container inside my Models but a blank page loads

**app.php**  
$container[‘pdo’] = function ($container) use ($config) {  
return new \Slim\PDO\Database($config[‘db’][‘dsn’], $config[‘db’][‘usr’], $config[‘db’][‘pw’]);  
};

**user.php**  
namespace App\Models;

```
class User extends Model
{

	protected $table = 'users';

	public function attempt($username,$password)
	{

		$selectStatement = $this->pdo->select()->from($table)->where('username', '=', $username);
		$stmt = $selectStatement->execute();
		$data = $stmt->fetch();
	
		if ($data) {
        	return true;
        }else{
        	return false;
        }
		
	}
}
```

---

<div class="post-metadata">

**Author:** ![rakma](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@rakma](https://discourse.slimframework.com/u/rakma)\
**Post date:** [February 23, 2017, 1:17pm UTC](https://discourse.slimframework.com/t/access-faapz-slim-pdo-from-container-in-model/1175/2 "2017-02-23T13:17:16Z")

</div>

I did a stupid mistake.

this  
$this-\>pdo-\>select()-\>from($table)-\>where(‘username’, ‘=’, $username);  
Should be  
$this-\>pdo-\>select()-\>from($this-\>table)-\>where(‘username’, ‘=’, $username);

---

<div class="post-metadata">

**Author:** ![tomynguyendn](https://avatars.discourse-cdn.com/v4/letter/t/f1d935/32.png) [@tomynguyendn](https://discourse.slimframework.com/u/tomynguyendn)\
**Post date:** [April 30, 2017, 3:32pm UTC](https://discourse.slimframework.com/t/access-faapz-slim-pdo-from-container-in-model/1175/3 "2017-04-30T15:32:27Z")

</div>

Hi rakma.

It looks like I also have a similar problem. Can you show me source code file **Model Class** and Controller where you use Model User.

Maybe after finished viewing, i can fix code by myself.

Please help me…
