thinkphp Model Call field value

Source: Internet
Author: User
How to get the field values just generated in the model when using the Thinkphp model auto-completion.

// 自动完成protected $_auto = array(    array('rand', 'random', self::MODEL_INSERT, 'function'), // 插入的时候生成随机数    array('password', 'encrypt', self::MODEL_INSERT, 'callback'),    array('login', 'time', 3, 'function'), // 对login字段在更新的时候写入当前时间戳    array('ip', 'get_client_ip', 3, 'function') , // 对ip字段在更新的时候自动获取ip地址);function encrypt($data){    // 此处怎么才能调用 rand 这个随机数    echo 'rand的随机数';}

Please ask the great God for your doubts. Kneeling thanks.

Reply content:

How to get the field values just generated in the model when using the Thinkphp model auto-completion.

// 自动完成protected $_auto = array(    array('rand', 'random', self::MODEL_INSERT, 'function'), // 插入的时候生成随机数    array('password', 'encrypt', self::MODEL_INSERT, 'callback'),    array('login', 'time', 3, 'function'), // 对login字段在更新的时候写入当前时间戳    array('ip', 'get_client_ip', 3, 'function') , // 对ip字段在更新的时候自动获取ip地址);function encrypt($data){    // 此处怎么才能调用 rand 这个随机数    echo 'rand的随机数';}

Please ask the great God for your doubts. Kneeling thanks.

Object-oriented:

$User = D("User"); // 实例化User对象$User->create(); // 生成数据对象echo $User->rand;//获取rand

I('post.rand')呢,,有没有试过?
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.