当前位置: 首页>>代码示例>>PHP>>正文


PHP UserData::getVal方法代码示例

本文整理汇总了PHP中UserData::getVal方法的典型用法代码示例。如果您正苦于以下问题:PHP UserData::getVal方法的具体用法?PHP UserData::getVal怎么用?PHP UserData::getVal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserData的用法示例。


在下文中一共展示了UserData::getVal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: releaseLive

function releaseLive($smarty, $msi, $user_id)
{
    //echo '<pre>'.print_r($_POST,true)."</pre>";
    /* First, get the data for the fields selected for release.
       Only consider fields that have been changed.
       User fields have data_id = 'u'
       Contact fields have data_id=address_id, phone_id, or e-mail_id
         for existing items, and -hold_id for adds. */
    $contact_id = $_POST['contact_id'];
    $user_data = new UserData($msi, $smarty, $user_id, $contact_id);
    $contact_data = new ContactData($msi, $smarty, $user_id, $contact_id);
    $err_msg = '';
    //echo '<pre>'.print_r($contact_data,true).'</pre>';
    //echo '<pre>'.print_r($user_data,true).'</pre>';
    $data_keys = array();
    foreach ($_POST as $key => $px) {
        if (substr($key, 0, 1) == 's') {
            $data_type = substr($key, 1, 1);
            // a, p, e, u
            $field_name = substr($key, strpos($key, '_', 3) + 1);
            /*echo '<br />data type, field name: '.$data_type.'  '.
              $field_name;*/
            if ($data_type == 'u') {
                $data_id = 'u';
                $trans_type = $user_data->getTransType($field_name);
                if ($trans_type != '') {
                    $val = $user_data->getVal($field_name);
                    $data_keys[] = array('data_type' => $data_type, 'data_id' => $data_id, 'trans_type' => $trans_type, 'field_name' => $field_name, 'val' => $val);
                }
            } else {
                $data_id = substr($key, 3, strpos($key, '_', 3) - 3);
                $trans_type = $contact_data->getTransType($data_type, $data_id, $field_name);
                //echo '<br />data id, trans type: '.$data_id.'  '.$trans_type;
                if ($trans_type != '') {
                    $val = $contact_data->getVal($data_type, $data_id, $field_name);
                    $data_keys[] = array('data_type' => $data_type, 'data_id' => $data_id, 'trans_type' => $trans_type, 'field_name' => $field_name, 'val' => $val);
                }
            }
        }
    }
    //echo '<pre>'.print_r($data_keys,true).'</pre>';
    sort($data_keys);
    //echo '<pre>data keys: '.print_r($data_keys,true).'</pre>';
    $data_id = '';
    $data_type = '';
    foreach ($data_keys as $px) {
        if ($data_id != $px['data_id'] || $data_type != $px['data_type']) {
            if ($data_id != '') {
                // update db
                setQuery($msi, $user_id, $data_type, $data_id, $contact_id, $trans_type, $userq, $addfields, $addvals, $changeq, $changew, $err_msg);
            }
            // (re-) set variables
            $data_id = $px['data_id'];
            $data_type = $px['data_type'];
            $c_count = false;
            $userq = '';
            $addfields = '';
            $addvals = '';
            $changeq = '';
            $changew = '';
            // where clause
        }
        $trans_type = $px['trans_type'];
        $field_name = $px['field_name'];
        $val = $px['val'];
        /*echo "<br />data_id, data_type, trans_type, field_name, val: ".
          "$data_id, $data_type, $trans_type, $field_name, $val";*/
        if ($data_type == 'u') {
            // user data
            if ($c_count) {
                // if there is already something in the list
                $userq .= ',';
            }
            if ($field_name == 'birth_date') {
                $userq .= $field_name . "=str_to_date('{$val}','%m/%d/%Y')";
            } else {
                $userq .= $field_name . "='" . $val . "'";
            }
        } else {
            // address, phone, or e-mail
            switch ($trans_type) {
                case 'add':
                    if ($val != '') {
                        if ($data_type == 'p' && $field_name == 'number') {
                            $val = str_replace(array('(', ')', ' ', '-'), "", $val);
                        }
                        if ($c_count) {
                            $addfields .= ',';
                            $addvals .= ',';
                        } else {
                            if ($data_type == 'p') {
                                $addfields = 'owner_id,formatted,';
                                $addvals = $contact_id . ',0,';
                            } else {
                                $addfields = 'owner_id,';
                                $addvals = $contact_id . ',';
                            }
                        }
                        $addfields .= $field_name;
                        $addvals .= "'" . $val . "'";
//.........这里部分代码省略.........
开发者ID:cottonwoodgulch,项目名称:alumni,代码行数:101,代码来源:releaselive.php


注:本文中的UserData::getVal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。