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


PHP f::dbInsert方法代码示例

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


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

示例1: post

 public static function post()
 {
     $form = f::dbFirstRow("select name, enabled_domains, detail \n\t\t\t\t\t\tfrom fm_forms \n\t\t\t\t\t\twhere id = {p:form_id} \n\t\t\t\t\t\tand client_id = {p:client_id} \n\t\t\t\t\t\tand (available_from = '' or available_from <= curdate()) \n\t\t\t\t\t\tand (available_to = '' or available_to >= curdate()) \n\t\t\t\t\t\tand status = 1");
     self::validateForm($form);
     if (f::hasErrors()) {
         return;
     }
     // get form data
     $formDetail = json_decode($form["detail"], true);
     $fields = $formDetail["fields"];
     // validate captcha
     if (isset($formDetail["captcha"]) && $formDetail["captcha"]) {
         f::validateParam("captcha", array("captcha"), "Wrong captcha");
     }
     $dataFields = self::validateFields($fields);
     if (f::hasErrors()) {
         return;
     }
     // validations are ok, then insert
     $userData = json_encode($dataFields, JSON_UNESCAPED_UNICODE);
     $siteTableId = "fm_userdata_" . substr("00" . f::getParam("client_id") * 1, -3);
     $insertId = f::dbInsert("insert into {d:siteTableId} set \n\t\t\t\t\t\t\t\tcreated_date = now(),\n\t\t\t\t\t\t\t\tstatus = 0,\n\t\t\t\t\t\t\t\tform_id = {p:form_id}, \n\t\t\t\t\t\t\t\tclient_id = {p:client_id}, \n\t\t\t\t\t\t\t\tuser_data = {userData}", array("siteTableId" => $siteTableId, "userData" => $userData));
     if (!$insertId) {
         f::setError(500, "Unexpected Error");
     } else {
         f::setResponseJson(array("ok" => true));
     }
 }
开发者ID:jumper9,项目名称:test,代码行数:28,代码来源:post.php

示例2: add

 public static function add()
 {
     if (!security::isLogged() || !USER_IS_ADMIN) {
         return;
     }
     $status = f::getParam("status");
     $name = f::getParam("name");
     $email = f::getParam("email");
     $password1 = trim(f::getParam("password1"));
     $password2 = trim(f::getParam("password2"));
     $exists = f::dbRes("select 1 from fm_users where name = {name}", array("name" => $name));
     if (!$email) {
         f::setError(400, "Email field is missing");
     } else {
         if (!$name) {
             f::setError(400, "Name field is missing");
         } else {
             if ($exists) {
                 f::setError(400, "Failed, user already exists.");
             }
         }
     }
     if ($status != 1 && $status != 0) {
         f::setError(400, "Incorrect Status");
     }
     if ($password1 && $password1 != $password2) {
         f::setError(400, "Incorrect Password");
     }
     if (!f::hasErrors()) {
         $userId = f::dbInsert("insert into fm_users set email = {email}, name = {name}, status = {status} ", array("email" => $email, "name" => $name, "status" => $status));
         if ($password1 && $password1 == $password2) {
             f::dbQuery("update fm_users set password = {pwd} where id = {userId}", array("pwd" => md5($password1), "userId" => $userId));
         }
         $userClients = f::getParam("userClients");
         f::dbQuery("delete from fm_users_clients where user_id = {userId}");
         foreach ($userClients as $clientId => $value) {
             f::dbQuery("insert into fm_users_clients set user_id = {userId}, client_id = {clientId}", array("userId" => $userId, "clientId" => $clientId));
         }
         f::setResponseJson(array("userId" => $userId));
     }
 }
开发者ID:jumper9,项目名称:test,代码行数:41,代码来源:users.php


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