<?php

// core/functions.php

require_once __DIR__ . '/../config/database.php';
require_once __DIR__ . '/helpers.php';

function get_all_symbols()
{
    $stmt = db()->query("SELECT * FROM symbols WHERE is_active = 1 ORDER BY sort_order ASC, symbol ASC");
    return $stmt->fetchAll();
}

function get_symbol_by_id($id)
{
    $stmt = db()->prepare("SELECT * FROM symbols WHERE id = ? LIMIT 1");
    $stmt->execute([(int)$id]);
    return $stmt->fetch();
}

function get_symbol_by_code($symbol)
{
    $stmt = db()->prepare("SELECT * FROM symbols WHERE symbol = ? LIMIT 1");
    $stmt->execute([$symbol]);
    return $stmt->fetch();
}