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


PHP DBQuery::get_last_id方法代码示例

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


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

示例1: date

    #print "$id $number texted: $message\n<p>\n";
    if ($number != '' && $message != '') {
        $date = date("Y-m-d H:i:s");
        $sql = "INSERT INTO location (latitude, longitude, location_name, location_date) ";
        $sql .= "VALUES('30.297017883372', '69.89501953125', '{$unknown_loc}', '{$date}') ;";
        $resl = mysql_query($sql);
        $loc_id = DBQuery::get_last_id();
        if (!$loc_id) {
            print "Could not add default location!";
            continue;
        }
        $sql = "INSERT INTO incident (incident_title, incident_mode, incident_dateadd, incident_date, location_id) ";
        $sql .= "VALUES ('" . mysql_real_escape_string($message) . "', '2', '{$date}', '{$date}', '{$loc_id}');";
        $ins = mysql_query($sql);
        print "<p>\n{$sql}\n<p>\n";
        $idIncident = DBQuery::get_last_id();
        if ($idIncident != '' && $ins) {
            #add phone number
            $sql = "INSERT INTO form_response (form_field_id, incident_id, form_response) VALUES ('1', '{$idIncident}', '" . mysql_real_escape_string($number) . "');";
            $ins = mysql_query($sql);
            print "<p>\n{$sql}\n<p>\n";
            $sql = "INSERT INTO incident_automated (idIncident, idMessage, status) VALUES ('{$idIncident}', '{$id}', 0);";
            $ins = mysql_query($sql);
            print "<p>\n{$sql}\n<p>\n";
        } else {
            print "\n<p>Error! Could not insert<p>\n";
        }
    }
}
//die;
/// SECOND, GET ALL INCIDENTS
开发者ID:unthinkingly,项目名称:ushahidi-crowdflower-plugin,代码行数:31,代码来源:post.php

示例2: implode

        $latitude = $worker_lat;
    }
    if ($longitude == 0 && $worker_long != '' && $worker_long != 0) {
        $longitude = $worker_long;
    }
}
$description = implode("\n", $translations) . "\n\nNotes:\n" . implode("\n", $notes);
$location_name = implode("  ", array_unique($locationnames));
$latitude = preg_replace("/[^0-9\\-\\.]/", "", $latitude);
$longitude = preg_replace("/[^0-9\\-\\.]/", "", $longitude);
$loc_id = "";
if ($latitude != '' && $longitude != '') {
    $sql = "INSERT INTO location (latitude, longitude, location_name, location_date) ";
    $sql .= "VALUES('{$latitude}', '{$longitude}', '" . mysql_real_escape_string($location_name) . "', '" . date("Y-m-d H:i:s") . "') ;";
    $res = mysql_query($sql);
    $loc_id = DBQuery::get_last_id();
    print "\nnew loc_id = {$loc_id}\n";
}
$sql = "UPDATE incident SET incident_description = '" . mysql_real_escape_string($description) . "'";
if ($loc_id != '') {
    $sql .= ", location_id = '{$loc_id}' ";
}
$sql .= " WHERE id = '{$id}' ; ";
if (preg_match('/WHERE id....[0-9]/', $sql)) {
    #preg match as a sanity check to make sure we are only updating one record inthe main incident table
    $res = mysql_query($sql);
    print "<p>\nUPDATED incident={$id}\n<p>";
}
foreach ($categories as $category) {
    $catd = preg_split('/\\|/', $category);
    $parent = trim($catd[0]);
开发者ID:unthinkingly,项目名称:ushahidi-crowdflower-plugin,代码行数:31,代码来源:index.php

示例3: update

 /**
  * Updates the
  *
  */
 public static function update($db_fields, $table_name, $pk_name = '')
 {
     if ($pk_name == '') {
         $pk_name = 'id' . $table_name;
     }
     if (array_key_exists($pk_name, $db_fields) && $db_fields[$pk_name] != '') {
         //update
         $sql = "UPDATE `{$table_name}` SET ";
         foreach ($db_fields as $field => $val) {
             if ($field == $pk_name || $val == '') {
                 continue;
             }
             $sql .= "`{$field}` = '" . mysql_real_escape_string($val) . "', ";
         }
         $sql = preg_replace('/, $/', '', $sql);
         //remove final comma
         $sql .= " WHERE `{$pk_name}` = '" . mysql_real_escape_string($db_fields[$pk_name]) . "'; ";
         if ($res = mysql_query($sql)) {
             return $db_fields[$pk_name];
         } else {
             //ERROR
             print "\nDID NOT UPDATE:\n{$sql}\n";
         }
     } else {
         $sql1 = "INSERT INTO `{$table_name}` (";
         $sql2 = "VALUES (";
         foreach ($db_fields as $field => $val) {
             if ($val == '') {
                 continue;
             }
             $sql1 .= "`{$field}`, ";
             $sql2 .= "'" . mysql_real_escape_string($val) . "', ";
         }
         $sql1 = preg_replace('/, $/', ')', $sql1);
         //remove final comma
         $sql2 = preg_replace('/, $/', ')', $sql2);
         //remove final comma
         $sql = $sql1 . $sql2 . ';';
         if ($res = mysql_query($sql)) {
             print "inserting";
             return DBQuery::get_last_id();
         } else {
             //ERROR
             print "\nDID NOT UPDATE:\n{$sql}\n";
         }
     }
 }
开发者ID:unthinkingly,项目名称:ushahidi-crowdflower-plugin,代码行数:51,代码来源:includes.php


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