duanmuyao0463 2018-04-02 13:17
浏览 83

让Yii2 ActiveRecord在内存而不是数据库上运行

I have an application doing calculations that uses Yii2 ActiveRecord to read and write to the database in various places. I need to rerun part of the calculation (for testing and integrity check purposes) without touching the database.

Is there a standard way to make ActiveRecord work on a data structure in memory? The data structure would consist of arrays with objects of the data models. I know this is a long shot, but the intention would be to avoid plan B which is having to locate all the places that interact with the database and refactor them so they can operate in dual mode (either memory structure or database).

$customer = new Customer();
$customer->name = 'ABC';
$customer->save();

In the above example, I would need a way to make save() add the new Customer to the memory data structure instead of the database.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 高德地图点聚合中Marker的位置无法实时更新
    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办