コード例 #1
0
function monthlySales($year)
{
    global $db;
    $sql = "SELECT s.qty,";
    $sql .= " DATE_FORMAT(s.date, '%Y-%m-%e') AS date,p.name,";
    $sql .= "SUM(p.sale_price * s.qty) AS total_saleing_price";
    $sql .= " FROM sales s";
    $sql .= " LEFT JOIN products p ON s.product_id = p.id";
    $sql .= " WHERE DATE_FORMAT(s.date, '%Y' ) = '{$year}'";
    $sql .= " GROUP BY DATE_FORMAT( s.date,  '%c' ),s.product_id";
    $sql .= " ORDER BY date_format(s.date, '%c' ) ASC";
    return find_by_sql($sql);
}
コード例 #2
0
ファイル: sql.php プロジェクト: antring/inventory-ks
function get_active_category($id)
{
    global $db;
    $sql = "SELECT r.categoryName FROM trade t LEFT JOIN returnCategory r ON t.FK_returnCategory = r.id WHERE t.id = {$id}";
    return find_by_sql($sql);
}
コード例 #3
0
function get_image_by_id($resturant_id)
{
    $sql = "SELECT image FROM image WHERE resturant_id={$resturant_id}";
    $result = find_by_sql($sql);
    return $result;
}