How do we find a list of people whose birthday is today from a database and perform an operation on them?
To start, we add the Foxdb library:
composer require webrium\foxdb In this way, write the default configuration for using the library and change it according to your project.
use Foxdb\DB; use Foxdb\Config; use Foxdb\DB; DB::addConnection('main', [ 'host'=>'localhost', 'port'=>'3306', 'database'=>'test', 'username'=>'root', 'password'=>'1234', 'charset'=>Config::UTF8, 'collation'=>Config::UTF8_GENERAL_CI, 'fetch'=>Config::FETCH_CLASS ]); Now, using a simple query, we can get the list of people whose birthday is today.
$list = DB::table('users') ->month('birth_date', date('m')) ->day('birth_date', date('d')) ->get(); See the GitHub repository and documentation at the link below.
Top comments (0)