findOne

Get one or specific record.

Usage:

$db->{table}->findOne($where)

Example:

$news = $db->news->findOne($where);
echo json_encode($news);

Return:

{
    "id": "1",
    "name": "Test News",
    "status": "ACTIVE",
    "created_at": "2024-11-03 21:07:37",
    "updated_at": null,
    "deleted_at": null
}

Using Primary ID for retrieval

$news = $db->news->findOne(1);
// {
//     "id": "1",
//     "name": "Test News",
//     "status": "ACTIVE",
//     "created_at": "2024-11-03 21:07:37",
//     "updated_at": null,
//     "deleted_at": null
// }

// If not existing
$news = $db->news->findOne(0);
// null

Using other columns for retrieval

$news = $db->news->findOne(
    array(
        'name' => 'Test News'
    )
);
// {
//     "id": "1",
//     "name": "Test News",
//     "status": "ACTIVE",
//     "created_at": "2024-11-03 21:07:37",
//     "updated_at": null,
//     "deleted_at": null
// }

Looking for the other parameters?

Last updated