What technologies or frameworks in PHP offer similar functionality to JPA in Java or LINQ in C# for handling database interactions with PHP classes?

To handle database interactions with PHP classes similar to JPA in Java or LINQ in C#, you can use an Object-Relational Mapping (ORM) library like Doctrine or Eloquent. These ORM libraries allow you to map PHP classes to database tables and perform CRUD operations using object-oriented syntax, making it easier to work with databases in PHP.

// Example using Doctrine ORM

// Include the Composer autoloader
require_once 'vendor/autoload.php';

// Create a new EntityManager
$entityManager = Doctrine\ORM\EntityManager::create($conn, $config);

// Define an entity class
/**
 * @Entity
 * @Table(name="users")
 */
class User {
    /** @Id @Column(type="integer") @GeneratedValue */
    protected $id;
    /** @Column(type="string") */
    protected $name;
}

// Retrieve all users
$users = $entityManager->getRepository(User::class)->findAll();

// Create a new user
$newUser = new User();
$newUser->setName('John Doe');
$entityManager->persist($newUser);
$entityManager->flush();