FaaPz/PDO

how to select particular fileds by this pdo plugin

Closed this issue · 2 comments

I want to select only particular column only from my table . for example I had user table consist of user id, user name, password, created_at and updated_at . I dwant fetch only the user name and password ..

I tried to achive the result by like this:

$selectStmt = $db->select('user_name' , 'password')->from('user');
$stmt = $selectStmt->execute();

$data = $stmt->fetechAll();

but i show an error .. Uncaught TypeError: Argument 1 passed to Slim\PDO\Database::select() must be of the type array

You have an error in your code because Slim\PDO\Database::select() accept an array as argument, so you have to change you code like this:
$selectStmt = $db->select(['user_name' , 'password'])->from('user');

Yes, its works .. thanks for your awesome reply @slackerzz