PHP code example of switon / query
1. Go to this page and download the library: Download switon/query library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
switon / query example snippets
use Switon\Core\Attribute\Autowired;
use Switon\Query\QueryBuilderInterface;
class UserService
{
#[Autowired] protected QueryBuilderInterface $queries;
public function latest(): array
{
return $this->queries->from('users')
->where(['status' => 1])
->orderBy(['created_at' => SORT_DESC])
->limit(10)
->all();
}
}