V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Aidenboss
V2EX  ›  C

作为初学者,写了一个简单的 C++ 使用代码转换成 SQL 语句的小小小程序

  •  
  •   Aidenboss · 2018-11-18 21:05:32 +08:00 · 2765 次点击
    这是一个创建于 1984 天前的主题,其中的信息可能已经有所发展或是发生改变。

    RT,作为 C++ 的初学者,写了一个简单的小工具。 DELETE 语句可以写成:

    Condition *passwordCondition = new Condition();
    passwordCondition->field(new string("password"))->ship(Ship::NOT_EXISTED);
    Where *where = new Where();
    where->condition(passwordCondition);
    
    Delete *aDelete = new Delete();
    aDelete->table(new string("user"))->where(where);
    cout << *aDelete->toString() << endl;
    

    output

    DELETE FROM user
    WHERE (`password` IS NULL)
    

    github 地址: https://github.com/yemingfeng/csql

    10 条回复    2018-11-19 14:08:23 +08:00
    misaka19000
        1
    misaka19000  
       2018-11-18 21:14:26 +08:00 via Android
    资瓷
    1010543618
        2
    1010543618  
       2018-11-18 22:04:38 +08:00
    感觉可以参考下这个 http://codeigniter.org.cn/user_guide/database/examples.html

    php 和 c 也很靠边嘛
    Aidenboss
        3
    Aidenboss  
    OP
       2018-11-18 22:06:26 +08:00
    @1010543618 现在只生成了 SQL 语句哈,可以准备和 MySQL Client 配合使用了。感谢提供的参考文档~
    Kilerd
        4
    Kilerd  
       2018-11-18 22:42:24 +08:00
    考虑下在 readme 里面吧代码块加上 语言标志,不然没有代码高亮
    Aidenboss
        5
    Aidenboss  
    OP
       2018-11-18 22:46:19 +08:00
    @Kilerd 谢谢反馈,已加
    lwh0328
        6
    lwh0328  
       2018-11-19 00:05:18 +08:00
    同样在学 C++,一起加油哦!
    shoujiaxin
        7
    shoujiaxin  
       2018-11-19 08:00:50 +08:00 via iPhone
    main 里 new 的指针好像都没有 delete ?还是用 shared_ptr 吧
    Aidenboss
        8
    Aidenboss  
    OP
       2018-11-19 09:35:06 +08:00
    @shoujiaxin 好的好的,确实没有 delete,老师教的都忘记了。过会儿补上。顺便学习下 shared_ptr。
    lqxandxy
        9
    lqxandxy  
       2018-11-19 14:06:42 +08:00
    要 c++11 吗? 还是 c++98 就可以用了
    Aidenboss
        10
    Aidenboss  
    OP
       2018-11-19 14:08:23 +08:00
    @lqxandxy IDE 是 clion,C++ 11 才可以。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5629 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 01:39 · PVG 09:39 · LAX 18:39 · JFK 21:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.