Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在PHP中创建通用DAO接口?_Java_Php_Dao - Fatal编程技术网

Java 如何在PHP中创建通用DAO接口?

Java 如何在PHP中创建通用DAO接口?,java,php,dao,Java,Php,Dao,我正在尝试用PHP编写一个通用DAO接口。我知道它在Java中是什么样子,但我只知道它在PHP中是什么样子 我在PHP中尝试过这个 <?php interface DAO { public function create($obj); public function read(); public function update($obj); public function delete($obj); } 通用DAO的最简单形式是在对象级别提供基本CR

我正在尝试用PHP编写一个通用DAO接口。我知道它在Java中是什么样子,但我只知道它在PHP中是什么样子

我在PHP中尝试过这个

<?php
 interface DAO {

    public function create($obj);
    public function read();
    public function update($obj);
    public function delete($obj);
 }

通用DAO的最简单形式是在对象级别提供基本CRUD操作,而不公开持久性机制的内部

interface UserDao
{
    /**
     * Store the new user and assign a unique auto-generated ID.
     */
    function create($user);

    /**
     * Return the user with the given auto-generated ID.
     */
    function findById($id);

    /**
     * Return the user with the given login ID.
     */
    function findByLogin($login);

    /**
     * Update the user's fields.
     */
    function update($user);

    /**
     * Delete the user from the database.
     */
    function delete($user);
}

通用DAO的最简单形式是在对象级别提供基本CRUD操作,而不公开持久性机制的内部

interface UserDao
{
    /**
     * Store the new user and assign a unique auto-generated ID.
     */
    function create($user);

    /**
     * Return the user with the given auto-generated ID.
     */
    function findById($id);

    /**
     * Return the user with the given login ID.
     */
    function findByLogin($login);

    /**
     * Update the user's fields.
     */
    function update($user);

    /**
     * Delete the user from the database.
     */
    function delete($user);
}