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


PHP Flight::ok方法代码示例

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


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

示例1: logout

 public static function logout()
 {
     $connection = Flight::dbMain();
     try {
         // $sql = "
         // DELETE FROM user
         // WHERE
         // id = :id";
         // $query = $connection->prepare($sql);
         // $query->bindParam(':id', $id, PDO::PARAM_INT);
         // $query->execute();
         $result = new Result();
         $result->Status = Result::SUCCESS;
         $result->Message = 'Done';
         //$result->Id = $id;
         Flight::ok($result);
     } catch (PDOException $pdoException) {
         Flight::error($pdoException);
     } catch (Exception $exception) {
         Flight::error($exception);
     } finally {
         $connection = null;
     }
 }
开发者ID:rhalf,项目名称:app_track,代码行数:24,代码来源:session.php

示例2: insert

 public static function insert()
 {
     $connection = Flight::dbMain();
     $dateTime = Flight::dateTime();
     try {
         $unitData = json_decode(file_get_contents("php://input"));
         if ($unitData == null) {
             throw new Exception(json_get_error());
         }
         /* Begin Transaction */
         $connection->beginTransaction();
         //Query 1 //=================================
         $sql = "\n\t\t\tINSERT INTO unitData \n\t\t\t(UnitData_imei, UnitData_serial_number, sim_id, UnitData_type_id, company_id, e_status_UnitData_id, UnitData_dt_created)\n\t\t\tVALUES\n\t\t\t(:UnitData_imei, :UnitData_serial_number, :sim_id, :UnitData_type_id, :company_id, :e_status_UnitData_id, :UnitData_dt_created);";
         $query = $connection->prepare($sql);
         $query->bindParam(':UnitData_imei', $unitData->Imei, PDO::PARAM_INT);
         $query->bindParam(':UnitData_serial_number', $unitData->SerialNumber, PDO::PARAM_STR);
         $query->bindParam(':sim_id', $unitData->Sim->Id, PDO::PARAM_INT);
         $query->bindParam(':UnitData_type_id', $unitData->UnitDataType->Id, PDO::PARAM_INT);
         $query->bindParam(':company_id', $unitData->Company->Id, PDO::PARAM_INT);
         $query->bindParam(':e_status_UnitData_id', $unitData->UnitDataStatus->Id, PDO::PARAM_INT);
         $query->bindParam(':UnitData_dt_created', $dateTime, PDO::PARAM_STR);
         $query->execute();
         $result = new Result();
         $result->Status = Result::INSERTED;
         $result->Id = $connection->lastInsertId();
         $result->Message = 'Done';
         //Query 2 //=================================
         $year = date('Y');
         $schema = "app_data_{$year}";
         // $tableName = "data_id_" .  $result->Id;
         $imei = $unitData->Imei;
         $tableName = "data_{$imei}";
         $sql = "\n\t\t\tCREATE TABLE IF NOT EXISTS `" . $schema . "`.`" . $tableName . "` (\n\t\t\t`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '',\n\t\t\t`dt_server` TIMESTAMP NULL COMMENT '',\n\t\t\t`dt_device` TIMESTAMP NULL COMMENT '',\n\t\t\t`command` SMALLINT NULL COMMENT '',\n\t\t\t`event` SMALLINT NULL COMMENT '',\n\t\t\t`byte` BIGINT NULL COMMENT '',\n\t\t\t`latitude` DOUBLE NULL COMMENT '',\n\t\t\t`longitude` DOUBLE NULL COMMENT '',\n\t\t\t`altitude` DOUBLE NULL COMMENT '',\n\t\t\t`rfid` BIGINT NULL COMMENT '',\n\t\t\t`mode` TINYINT NULL COMMENT '',\n\t\t\t`speed` SMALLINT NULL COMMENT '',\n\t\t\t`time` BIGINT NULL COMMENT '',\n\t\t\t`odometer` BIGINT NULL COMMENT '',\n\t\t\t`heading` SMALLINT NULL COMMENT '',\n\t\t\t`picture` BIGINT NULL COMMENT '',\n\t\t\t`gps_satellite` SMALLINT NULL COMMENT '',\n\t\t\t`gps_status` SMALLINT NULL COMMENT '',\n\t\t\t`gps_accuracy` SMALLINT NULL COMMENT '',\n\t\t\t`gprs_signal` SMALLINT NULL COMMENT '',\n\t\t\t`gprs_status` VARCHAR(25) NULL COMMENT '',\n\t\t\t`di_0` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_1` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_2` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_3` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_4` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_5` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_6` SMALLINT NULL COMMENT '',\n\t\t\t`di_7` SMALLINT NULL COMMENT '',\n\t\t\t`di_8` SMALLINT NULL COMMENT '',\n\t\t\t`di_9` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_10` TINYINT(1) NULL COMMENT '',\n\t\t\t`do_0` TINYINT(1) NULL COMMENT '',\n\t\t\t`do_1` TINYINT(1) NULL COMMENT '',\n\t\t\t`do_2` TINYINT(1) NULL COMMENT '',\n\t\t\t`do_3` TINYINT(1) NULL COMMENT '',\n\t\t\t`ai_0` SMALLINT NULL COMMENT '',\n\t\t\t`ai_1` SMALLINT NULL COMMENT '',\n\t\t\t`ai_2` SMALLINT NULL COMMENT '',\n\t\t\t`ai_3` SMALLINT NULL COMMENT '',\n\t\t\t`ai_4` SMALLINT NULL COMMENT '',\n\t\t\t`ai_5` SMALLINT NULL COMMENT '',\n\t\t\t`ai_6` SMALLINT NULL COMMENT '',\n\t\t\t`ai_7` SMALLINT NULL COMMENT '',\n\t\t\t`ai_8` SMALLINT NULL COMMENT '',\n\t\t\t`ai_9` SMALLINT NULL COMMENT '',\n\t\t\t`ao_0` SMALLINT NULL COMMENT '',\n\t\t\t`ao_1` SMALLINT NULL COMMENT '',\n\t\t\t`ao_2` SMALLINT NULL COMMENT '',\n\t\t\t`ao_3` SMALLINT NULL COMMENT '',\n\t\t\tPRIMARY KEY (`id`)  COMMENT '')\n\t\t\tENGINE = InnoDB\n\t\t\tPACK_KEYS = DEFAULT\n\t\t\tKEY_BLOCK_SIZE = 8;";
         $query = $connection->prepare($sql);
         $query->execute();
         $connection->commit();
         Flight::ok($result);
     } catch (PDOException $pdoException) {
         $connection->rollBack();
         Flight::error($pdoException);
     } catch (Exception $exception) {
         $connection->rollBack();
         Flight::error($exception);
     } finally {
         $connection = null;
     }
 }
开发者ID:rhalf,项目名称:app_track,代码行数:47,代码来源:unitdata.php

示例3: function

        Flight::error($exception);
    }
});
Flight::route('POST /v1/main/poi', function () {
    try {
        $object = Poi::insert();
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('PUT /v1/main/poi/@id', function ($id) {
    try {
        $object = Poi::update($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('DELETE /v1/main/poi/@id', function ($id) {
    try {
        $object = Poi::delete($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
//=========================================================================
Flight::set('flight.log_errors', true);
Flight::set('flight.handle_errors', true);
Flight::start();
开发者ID:rhalf,项目名称:app_track,代码行数:31,代码来源:main.php


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