Aidenboss
V2EX  ›  C

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

  •  
  •   Aidenboss · Nov 18, 2018 · 4050 views
    This topic created in 2911 days ago, the information mentioned may be changed or developed.

    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 replies  •  2018-11-19 14:08:23 +08:00
    misaka19000
    misaka19000
    Nov 18, 2018 via Android
    1
    资瓷
    1010543618
    1010543618
    Nov 18, 2018
    2
    感觉可以参考下这个 http://codeigniter.org.cn/user_guide/database/examples.html

    php 和 c 也很靠边嘛
    Aidenboss
    Aidenboss
    OP
    Nov 18, 2018
    3
    @1010543618 现在只生成了 SQL 语句哈,可以准备和 MySQL Client 配合使用了。感谢提供的参考文档~
    Kilerd
    Kilerd
    Nov 18, 2018
    4
    考虑下在 readme 里面吧代码块加上 语言标志,不然没有代码高亮
    Aidenboss
    Aidenboss
    OP
    Nov 18, 2018
    5
    @Kilerd 谢谢反馈,已加
    lwh0328
    lwh0328
    Nov 19, 2018
    6
    同样在学 C++,一起加油哦!
    shoujiaxin
    shoujiaxin
    Nov 19, 2018 via iPhone
    7
    main 里 new 的指针好像都没有 delete ?还是用 shared_ptr 吧
    Aidenboss
    Aidenboss
    OP
    Nov 19, 2018
    8
    @shoujiaxin 好的好的,确实没有 delete,老师教的都忘记了。过会儿补上。顺便学习下 shared_ptr。
    lqxandxy
    lqxandxy
    Nov 19, 2018
    9
    要 c++11 吗? 还是 c++98 就可以用了
    Aidenboss
    Aidenboss
    OP
    Nov 19, 2018
    10
    @lqxandxy IDE 是 clion,C++ 11 才可以。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1583 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 90ms · UTC 12:25 · PVG 20:25 · LAX 04:25 · JFK 07:25
    ♥ Do have faith in what you're doing.