fatfree框架,bug pr misuse?

时间:2017-12-20 17:23:33

标签: php mysql fat-free-framework

我在f3框架中有这个db函数

static int Main(string[] args)
{
    var keeper = new ObjectKeeper();
    var factory = new ObjectFactoryMulti2();
    var server = new ServerDef()
    {
        MachineDNSName = "sas.server.com`",
        Protocol = Protocols.ProtocolBridge,
        Port = 8591,
        BridgeSecurityPackage = "Negotiate",
        MaxPerObjectPool = Environment.ProcessorCount,
        RunForever = true,
        RecycleActivationLimit = 100,
    };
    var login = new LoginDef();

    var pool = factory.ObjectPools.CreatePoolByServer("Pool1", server, login);
    var lease = pool.GetPooledObject(null, null, 5000);
    var workspace = (IWorkspace)lease.SASObject;

    keeper.AddObject(1, workspace.UniqueIdentifier, workspace);

    try
    {
        using (var conn = new OleDbConnection("Provider=SAS.IOMProvider.1; Data Source=iom-id://" + workspace.UniqueIdentifier))
        {
            // throws System.Data.OleDb.OleDbException: 'The object 1EFCE532-99BA-4A27-AF37-574EAE1CD04C could not be found; make sure it was previously added to the object keeper.'
            conn.Open();
        }
    }
    catch (Exception ex)
    {
        System.Console.Error.WriteLine(ex.ToString());
        return 1;
    }
    finally
    {
        keeper.RemoveObject(workspace);
        lease.ReturnToPool();
        pool.Shutdown();
    }

    return 0;
}

似乎sumamount不正确,从f3日志中我执行了这个查询

public function sumOfAmount($startdate, $enddate) {
    $this->amount = 'price*quantity';
    $this->sumamount = 'SUM(price*quantity)';
    $this->load(array('createon > ? AND createon < ?', $startdate, $enddate));

    //return $this->query;
    return $this->cast();
}

但如果我在phpmyadmin中运行该查询,结果还可以

任何想法??

1 个答案:

答案 0 :(得分:1)

我好像忘记了 group by 子句

public function sumOfAmount($startdate, $enddate) {
    $this->amount = 'price*quantity';
    $this->sumamount = 'SUM(price*quantity)';
    $this->load(array('createon > ? AND createon < ?', $startdate, $enddate,'group' => 'idline'));

    //return $this->query;
    return $this->cast();
}