0

我的任务是从具有大于或等于 2 年经验的表中获取员工列表。我有'joined_date'表中的字段。我employee正在使用 cakephp 框架。你能建议我获取详细信息的方法吗?提前谢谢。

4

1 回答 1

0

您首先需要使用各种方法之一连接到数据库。然后使用 SQL 获取记录。

假设joined_date字段是一个时间戳,并且在一个名为employee ...

这是使用 odbc_connect 的示例...

<?php
    // Connect to the database
    $conn = odbc_connect($server ,$username ,$password );

    // Define the query
    $query = "
        SELECT * FROM employee
        WHERE joined_date >= now() - INTERVAL 2 YEAR
    ";

    // Execute the query and assign the results to a resource
    $res = odbc_exec($conn,trim($query));

    // Loop through the results 
    while($row = odbc_fetch_array($res)) 
    {
        print_r($row);
    }

    // Close the connection
    odbc_close($conn);
?>

PHP odbc_connect

MySQL 日期和时间函数

于 2013-03-01T17:33:10.333 回答