find

Get or retrieve array of datas.

Usage:

$db->{table}->find();
$db->{table}->find($where);

Example:

$news = $db->news->find();
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
    },
    ...
]

You can also pass options in the function:

Using Primary ID

$news = $db->news->find(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->find(0);
// []

Using other columns for retrieval

$news = $db->news->find(
    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