// Load the 'Users' table $usersTable = \Cake\ORM\TableRegistry::get('Users'); // Get all the users from the 'Users' table $users = $usersTable->find()->all();
// Define a custom connection configuration $customConfig = [ 'host' => 'localhost', 'username' => 'custom_user', 'password' => 'custom_password', 'database' => 'custom_database', 'driver' => 'Cake\Database\Driver\Mysql', 'url' => env('DATABASE_URL', null), ]; // Load the 'Posts' table with the custom connection configuration $postsTable = \Cake\ORM\TableRegistry::get('Posts', [ 'connection' => $customConfig ]); // Get all the posts from the 'Posts' table $posts = $postsTable->find()->all();These examples demonstrate how the TableRegistry class can be used to load and use tables in a CakePHP application. The package library associated with this class is the ORM (Object-Relational Mapping) library, which is responsible for mapping database tables to objects in your application.