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


PHP returnJson函数代码示例

本文整理汇总了PHP中returnJson函数的典型用法代码示例。如果您正苦于以下问题:PHP returnJson函数的具体用法?PHP returnJson怎么用?PHP returnJson使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: GenericSQL

/**
 * This is a generic SQL function.  You input the appropriate variables
 * and the function does all the SQL for you and returns information based
 * on SQL type (Update / Insert / Select / Delete) in a consistent manner. 
 *
 * @param $sql                  SQL Statement
 * @param $param_type_array     SQL Param Types (integer, string, etc)
 * @param $param_array          SQL Params
 * @param $sql_op               SQL Operations (Update, Insert, Select, Delete)
 *
 * UPDATE / INSERT / DELETE:
 * @return                      Success / Failure / Warning Codes (Constants)
 *
 * SELECT:
 * @return                      JSON Object / Failure Codes
 * */
function GenericSQL($sql, $param_type_array, $param_array, $sql_op)
{
    global $mysqli;
    try {
        if ($stmt = $mysqli->prepare($sql)) {
            if ($param_type_array !== NULL && $param_array !== NULL) {
                call_user_func_array(array($stmt, "bind_param"), array_merge(passByReference($param_type_array), passByReference($param_array)));
            }
            $stmt->execute();
            if ($stmt->affected_rows === 0 && $sql_op !== SQL_SELECT) {
                return NOTHING_AFFECTED;
            } elseif ($stmt->affected_rows === -1 && $sql_op !== SQL_SELECT) {
                return $stmt->errno;
            } elseif ($sql_op === SQL_SELECT) {
                $data = returnJson($stmt);
                return $data;
            } else {
                return SUCCESS;
            }
        } else {
            // Throw error
            fwrite(STDOUT, "else");
            return FAILURE;
        }
    } catch (Exception $e) {
        // Return generic error
        fwrite(STDOUT, "exception");
        return FAILURE;
    }
}
开发者ID:evreichard,项目名称:PHPlackjack,代码行数:46,代码来源:dbCommunication.php

示例2: actionUpload

 public function actionUpload()
 {
     $params = \Yii::$app->request->post();
     $name = $params['name'];
     $filetype = $params['filetype'];
     if (\Yii::$app->request->isPost) {
         $model = new Uploadform();
         $model->setFileTableName($model::TABLE_NAME_SHOP_CONFIG);
         $model->file = UploadedFile::getInstance($model, $name);
         if ($model->file) {
             $data = array();
             $data[$model->formName()]['table_name'] = $model->getFileTableName();
             $data[$model->formName()]['file_type'] = $filetype ?: $model::FILE_TYPE_IMAGE;
             $data[$model->formName()]['file_ext'] = $model->file->getExtension();
             if ($id = $model->create($data)) {
                 $file = $model->file_dir . $model->file_name;
                 $file = \Yii::getAlias($file);
                 $rs = $model->file->saveAs($file);
                 $data = ['file_name' => $model->file_name, 'img_src' => getImageHost() . $model->getDir() . $model->file_name];
                 returnJson(1, '成功!', $data);
             } else {
                 $errors = $model->getFirstErrors();
                 $errorInfo = array_shift($errors);
                 returnJson(0, '失败!' . $errorInfo);
             }
             return;
         }
     }
     returnJson(0, '失败,请选择要上传的文件!');
 }
开发者ID:xiaohongyang,项目名称:yii_shop,代码行数:30,代码来源:Shop_configController.php

示例3: checkLogin

 protected function checkLogin()
 {
     $user['email'] = $this->input->post('email');
     $user['password'] = $this->input->post('password');
     $userData = $this->Account_Model->getUser($user);
     if (isset($userData) && $userData) {
         // 			bug($userData);
         $this->userSession = array('fullname' => $userData->fullname, 'uid' => $userData->uid, 'lang' => 'vi');
         $this->session->set_userdata($this->userSession);
         $continue = $this->input->get('r') ? $this->input->get('r') : '';
         if ($this->input->get('format') == 'json') {
             return returnJson(true);
         } else {
             redirect($continue);
         }
     } else {
         unset($_POST);
         $this->msg[] = array('type' => 'error', 'text' => $this->lang->line('Login False'));
         if ($this->input->get('format') == 'json') {
             return returnJson(false);
         } else {
             return self::login();
         }
     }
 }
开发者ID:quanict,项目名称:parkornleather,代码行数:25,代码来源:account.php

示例4: report

 public function report()
 {
     $data = array();
     if (isset($_POST['content']) && $_POST['content']) {
         $data['content'] = addslashes($_POST['content']);
     }
     if (isset($_POST['img_ids']) && $_POST['img_ids']) {
         $imgArr = explode(',', $_POST['img_ids']);
         $len = count($imgArr);
         $len > 2 && ($len = 2);
         for ($i = 1; $i <= $len; $i++) {
             $data['img_id' . $i] = $imgArr[$i - 1];
         }
     }
     if ($data) {
         if (isset($_POST['qqmail']) && $_POST['qqmail']) {
             $data['qqmail'] = $_POST['qqmail'];
         }
         $oIp = D('ip');
         $ip = $oIp->get_client_ip();
         $iIp = $oIp->getInt($ip);
         $data['ip'] = $iIp;
         $data['time'] = NOW;
         D('UserReport')->insert($data);
     }
     returnJson(SUCCESS, '', '操作成功!');
 }
开发者ID:beelibrary820145,项目名称:tanxiongfeng,代码行数:27,代码来源:UserReportAction.class.php

示例5: extend

 function extend($path = '')
 {
     if (empty($path)) {
         returnJson('1002', '模板路径错误!');
     } else {
         $page = Page::init();
         $page->extend($path);
     }
 }
开发者ID:imjcw,项目名称:terse,代码行数:9,代码来源:Page.php

示例6: deleteArticle

 public function deleteArticle()
 {
     $id = $_GET['id'];
     if (empty($id)) {
         return returnJson('1003', '未指定需要查找的文章ID!');
     }
     $id = intval($id);
     return $this->delete(array('id' => $id));
 }
开发者ID:imjcw,项目名称:terse,代码行数:9,代码来源:ArticleModel.php

示例7: addPraise

 public function addPraise()
 {
     $data = array(array('obj_id', 'int'));
     dataFilter($data, 'post');
     $user_id = 1;
     $rs = D('Praise')->addPraise($user_id, $data['obj_id']);
     $msg = $rs == -1 ? '取消点赞成功!' : '点赞成功!';
     returnJson(SUCCESS, $msg);
 }
开发者ID:beelibrary820145,项目名称:tanxiongfeng,代码行数:9,代码来源:PraiseAction.class.php

示例8: alterAddr

 /**
  * 地址修改
  */
 public function alterAddr()
 {
     codecheck();
     $data = array(array('addr', 'string'), array('name', 'string'), array('phone', 'string'), array('id', 'int'));
     dataFilter($data, 'post');
     $id = $data['id'];
     unset($data['id']);
     D('Address')->update($data, 'cust_id=' . $_SESSION['userinfo']['id'] . ' AND id=' . $id);
     returnJson(SUCCESS, '', '操作成功');
 }
开发者ID:beelibrary820145,项目名称:tanxiongfeng,代码行数:13,代码来源:AddressAction.class.php

示例9: model

 function model($model = '')
 {
     if (empty($model)) {
         return returnJson('1003', '未指定model名!');
     }
     $model = ucfirst($model);
     $class = $model . 'Model';
     require_once ROOT . '/app/Models/' . $class . '.php';
     return new $class();
 }
开发者ID:imjcw,项目名称:terse,代码行数:10,代码来源:Helper.php

示例10: readArticalDeal

 /**
  * artical detail
  */
 public static function readArticalDeal()
 {
     $requestReticalInfo = Flight::request()->query->getData();
     if (ifNoEmptyData($requestReticalInfo)) {
         $result = ReadService::articalDetail($requestReticalInfo);
         returnJson(false, $result['data'], throwInfo($result['errorn']));
     } else {
         returnJson(false, null, throwInfo(404));
     }
 }
开发者ID:Birjemin,项目名称:Cmd_library,代码行数:13,代码来源:readController.php

示例11: doDelete

 public function doDelete()
 {
     $id = intval($_GET['id']);
     if (empty($id)) {
         return returnJson('error');
     }
     $column_biz = new ColumnBiz();
     $result = $column_biz->deleteColumn($id);
     $page = $result ? 'index' : '/error';
     return redirect($page);
 }
开发者ID:imjcw,项目名称:terse,代码行数:11,代码来源:ColumnController.php

示例12: sendMsg

 /**
  * 发送消息
  */
 public function sendMsg()
 {
     $cust_id = 2;
     $data = array(array('target_id', 'int'), array('msg_type', 'int'), array('msg', 'string'), array('perOrGroup', 'int'));
     dataFilter($data, 'post');
     $user_id = $group_id = 0;
     $data['perOrGroup'] == 1 ? $user_id = $data['target_id'] : ($group_id = $data['target_id']);
     $userData = array('um_cust_id' => $cust_id, 'um_receive_userid' => $user_id, 'um_perOrGroup' => $data['perOrGroup'], 'um_group_id' => $group_id);
     $conData = array('cm_time' => NOW, 'cm_content' => $data['msg'], 'cm_type' => $data['msg_type']);
     $msg_id = D('Chatmsg')->sendMsg($userData, $conData);
     $retData = array('msg_id' => $msg_id, 'msg' => $data['msg'], 'msg_type' => $data['msg_type'], 'msg_time' => $data['msg'], 'perOrGroup' => $data['perOrGroup'], 'receive_userid' => $user_id, 'group_id' => $group_id);
     returnJson(SUCCESS, $retData);
 }
开发者ID:beelibrary820145,项目名称:tanxiongfeng,代码行数:16,代码来源:TextMsgAction.class.php

示例13: connect

 public function connect()
 {
     $this->config = $this->getConfig();
     $this->con = mysql_connect($this->config['DB_HOST'], $this->config['DB_USERNAME'], $this->config['DB_PASSWORD']);
     if (!$this->con) {
         returnJson('1001', '数据库连接错误!');
     }
     //Helper::dd($this->table);
     $con_db = mysql_select_db($this->config['DB_NAME'], $this->con);
     if (!$con_db) {
         returnJson('1001', '数据库不存在!');
     }
     mysql_query('set names utf8');
 }
开发者ID:imjcw,项目名称:terse,代码行数:14,代码来源:Connection.php

示例14: getUsernameData

function getUsernameData($id)
{
    global $mysqli;
    $sql = "SELECT userName FROM bs_users WHERE userId = ?";
    try {
        if ($stmt = $mysqli->prepare($sql)) {
            $stmt->bind_param("i", $id);
            return returnJson($stmt);
            $stmt->close();
            $mysqli->close();
        }
    } catch (Exception $e) {
        log_error($e, $sql, null);
        return false;
    }
}
开发者ID:ans2759,项目名称:battleship,代码行数:16,代码来源:userData.php

示例15: save

 public function save()
 {
     $path = date('Y-m', NOW);
     $oImg = D('Image.Image');
     $iniData = array('dirPath' => COMMON_PATH . 'Image/' . $path . '/');
     $oImg->setParam($iniData);
     $im = $oImg->init($_FILES['fname']);
     //$im=$oImg->compress($im,400,0);
     //$im=$oImg->rotate($im,30);
     //$im=$oImg->textWater($im,'this is a test');
     //$im=$oImg->imageWater($im,COMMON_PATH.'Image/test.jpg');
     $rs = $oImg->saveImage($im);
     $inData = array('src' => DOMAIN . 'Common/Image/' . $path . '/' . $rs['name'], 'w' => $rs['w'], 'h' => $rs['h'], 'time' => NOW);
     $rs = D('Img')->insert($inData);
     unset($inData['time']);
     $inData['id'] = $rs;
     returnJson(SUCCESS, $inData);
 }
开发者ID:beelibrary820145,项目名称:tanxiongfeng,代码行数:18,代码来源:ImgAction.class.php


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