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


PHP Database::insert方法代码示例

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


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

示例1: index

 public function index()
 {
     $db = new Database();
     $incidents = $db->query("SELECT incident.id, incident_title, \n\t\t\t\t\t\t\t\t incident_description, incident_verified, \n\t\t\t\t\t\t\t\t location.latitude, location.longitude, alert_sent.incident_id\n\t\t\t\t\t\t\t\t FROM incident INNER JOIN location ON incident.location_id = location.id\n\t\t\t\t\t\t\t\t LEFT OUTER JOIN alert_sent ON incident.id = alert_sent.incident_id");
     $config = kohana::config('alerts');
     $sms_from = NULL;
     $settings = ORM::factory('settings', 1);
     if ($settings->loaded == true) {
         // Get SMS Numbers
         if (!empty($settings->sms_no3)) {
             $sms_from = $settings->sms_no3;
         } elseif (!empty($settings->sms_no2)) {
             $sms_from = $settings->sms_no2;
         } elseif (!empty($settings->sms_no1)) {
             $sms_from = $settings->sms_no1;
         } else {
             $sms_from = "000";
         }
         // User needs to set up an SMS number
     }
     foreach ($incidents as $incident) {
         if ($incident->incident_id != NULL) {
             continue;
         }
         $verified = (int) $incident->incident_verified;
         if ($verified) {
             $latitude = (double) $incident->latitude;
             $longitude = (double) $incident->longitude;
             $proximity = new Proximity($latitude, $longitude);
             $alertees = $this->_get_alertees($proximity);
             foreach ($alertees as $alertee) {
                 $alert_type = (int) $alertee->alert_type;
                 if ($alert_type == 1) {
                     $sms = new Eflyer();
                     $sms->user = $settings->eflyer_username;
                     $sms->password = $settings->eflyer_password;
                     $sms->use_ssl = false;
                     $sms->sms();
                     $message = $incident->incident_description;
                     if ($sms->send($alertee->alert_recipient, $message) == "OK") {
                         $db->insert('alert_sent', array('alert_id' => $alertee->id, 'incident_id' => $incident->id, 'alert_date' => date("Y-m-d H:i:s")));
                         $db->clear_cache(true);
                     }
                 } elseif ($alert_type == 2) {
                     $to = $alertee->alert_recipient;
                     $from = $config['alerts_email'];
                     $subject = $incident->incident_title;
                     $message = $incident->incident_description;
                     if (email::send($to, $from, $subject, $message, TRUE) == 1) {
                         $db->insert('alert_sent', array('alert_id' => $alertee->id, 'incident_id' => $incident->id, 'alert_date' => date("Y-m-d H:i:s")));
                         $db->clear_cache(true);
                     }
                 }
             }
         }
     }
 }
开发者ID:shukster,项目名称:Cuidemos-el-Voto,代码行数:57,代码来源:alerts.php

示例2: load

 public function load()
 {
     $db = new Database();
     $db->delete('Users', 'StudentId is not null');
     $db->delete('Students', '1=1');
     $db->select('Settings', 'SrProjectUrl,SrProjectToken');
     $settings = $db->getResult();
     $students = json_decode(file_get_contents($settings['SrProjectUrl'] . '/getAll/' . $settings['SrProjectToken']));
     foreach ($students as $student) {
         $db->insert('Students', array('id' => $student->id, 'Project' => $student->projectTitle, 'Location' => 'TBA'));
         $db->insert('Users', array('Email' => $student->email . '@fiu.edu', 'FirstName' => ucfirst($student->firstName), 'LastName' => ucfirst($student->lastName), 'StudentId' => $student->id, 'Roles' => 'student', 'DefaultRole' => 'student'));
     }
     return true;
 }
开发者ID:M7ammed,项目名称:Mobile-Judge-App,代码行数:14,代码来源:Students.php

示例3: convertOptionBatch

 /**
  * @param ResultWrapper $res
  * @param Database $dbw
  * @return null|int
  */
 function convertOptionBatch($res, $dbw)
 {
     $id = null;
     foreach ($res as $row) {
         $this->mConversionCount++;
         $insertRows = [];
         foreach (explode("\n", $row->user_options) as $s) {
             $m = [];
             if (!preg_match("/^(.[^=]*)=(.*)\$/", $s, $m)) {
                 continue;
             }
             // MW < 1.16 would save even default values. Filter them out
             // here (as in User) to avoid adding many unnecessary rows.
             $defaultOption = User::getDefaultOption($m[1]);
             if (is_null($defaultOption) || $m[2] != $defaultOption) {
                 $insertRows[] = ['up_user' => $row->user_id, 'up_property' => $m[1], 'up_value' => $m[2]];
             }
         }
         if (count($insertRows)) {
             $dbw->insert('user_properties', $insertRows, __METHOD__, ['IGNORE']);
         }
         $dbw->update('user', ['user_options' => ''], ['user_id' => $row->user_id], __METHOD__);
         $id = $row->user_id;
     }
     return $id;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:31,代码来源:convertUserOptions.php

示例4: populateInterwikiTable

 /**
  * Common function for databases that don't understand the MySQLish syntax of interwiki.sql.
  *
  * @return Status
  */
 public function populateInterwikiTable()
 {
     $status = $this->getConnection();
     if (!$status->isOK()) {
         return $status;
     }
     $this->db->selectDB($this->getVar('wgDBname'));
     if ($this->db->selectRow('interwiki', '*', [], __METHOD__)) {
         $status->warning('config-install-interwiki-exists');
         return $status;
     }
     global $IP;
     MediaWiki\suppressWarnings();
     $rows = file("{$IP}/maintenance/interwiki.list", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
     MediaWiki\restoreWarnings();
     $interwikis = [];
     if (!$rows) {
         return Status::newFatal('config-install-interwiki-list');
     }
     foreach ($rows as $row) {
         $row = preg_replace('/^\\s*([^#]*?)\\s*(#.*)?$/', '\\1', $row);
         // strip comments - whee
         if ($row == "") {
             continue;
         }
         $row .= "|";
         $interwikis[] = array_combine(['iw_prefix', 'iw_url', 'iw_local', 'iw_api', 'iw_wikiid'], explode('|', $row));
     }
     $this->db->insert('interwiki', $interwikis, __METHOD__);
     return Status::newGood();
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:36,代码来源:DatabaseInstaller.php

示例5: write_log

 public static function write_log($modul, $aksi, $referensi)
 {
     $db = new Database();
     $pesan = "modul " . strtoupper($modul) . " aksi " . strtoupper($aksi) . " referensi " . $referensi;
     $ip = '';
     if ($_SERVER['HTTP_CLIENT_IP']) {
         $ip = $_SERVER['HTTP_CLIENT_IP'];
     } elseif ($_SERVER['HTTP_X_FORWARDED_FOR']) {
         $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
     } elseif ($_SERVER['HTTP_X_FORWARDED']) {
         $ip = $_SERVER['HTTP_X_FORWARDED'];
     } elseif ($_SERVER['HTTP_FORWARDED_FOR']) {
         $ip = $_SERVER['HTTP_FORWARDED_FOR'];
     } elseif ($_SERVER['HTTP_FORWARDED']) {
         $ip = $_SERVER['HTTP_FORWARDED'];
     } elseif ($_SERVER['REMOTE_ADDR']) {
         $ip = $_SERVER['REMOTE_ADDR'];
     } else {
         $ip = 'UNKNOWN';
     }
     $now = date('Y-m-d h:i:s');
     $data = array('USER' => Session::get('user'), 'AKTIFITAS_EL' => $pesan, 'TIME_STAMP_EL' => $now, 'IP_ADDRESS_EL' => $ip);
     //        var_dump($data);
     //        echo Session::get('user')." ".$pesan." ".$ip." ".$now;
     $db->insert('d_entry_log', $data);
 }
开发者ID:nazimkabiri,项目名称:sims-beasiswa,代码行数:26,代码来源:ClassLog.php

示例6: process

 public function process()
 {
     $tag = $this->get('tag');
     $type = $this->get('type');
     if (empty($tag)) {
         throw new Error_Api('Пропущено обязательное поле: tag', Error_Api::MISSING_INPUT);
     }
     if (empty($type)) {
         throw new Error_Api('Пропущено обязательное поле: type', Error_Api::MISSING_INPUT);
     }
     if (!array_key_exists($type, $this->types)) {
         throw new Error_Api('Неправильно заполнено поле: type', Error_Api::INCORRECT_INPUT);
     }
     $color = $this->types[$type];
     $tag = trim(undo_safety($tag));
     $args = array($tag, '|' . $tag . '|', $tag);
     $exists = Database::get_field('tag', 'alias', 'name = ? or locate(?, variants) or alias = ?', $args);
     if ($exists) {
         $alias = $exists;
     } else {
         $alias = Transform_Meta::make_alias($tag);
         Database::insert('tag', array('alias' => $alias, 'name' => $tag, 'variants' => '|'));
         $this->add_error(Error_Api::UNKNOWN_TAG);
     }
     Database::update('tag', array('color' => $color), 'alias = ?', $alias);
     $this->set_success(true);
     $this->add_answer('tag', $alias);
 }
开发者ID:4otaku,项目名称:4otaku,代码行数:28,代码来源:tag.php

示例7: add

    public function add($concepto, $moneda, $monto, $tipo_op)
    {
        include_once '../db.php';
        $db = new Database();
        $db->connect();
        $valores = array();
        $valores[0] = '"' . $concepto . '"';
        $valores[1] = $moneda;
        $valores[2] = $monto;
        $valores[3] = '"' . date('Y-m-d') . '"';
        $valores[4] = $monto;
        $valores[5] = $tipo_op;
        $valores[6] = '"' . $_SESSION[userPagos] . '"';
        $valores[7] = 1;
        $valores[8] = 0;
        if ($moneda == 1) {
            $dolar = new dolar();
            $dolarCompra = $dolar->getDolar();
            $valores[4] = round($monto * $dolarCompra, 2);
        }
        $idCreated = $db->insert('pagos', $valores, 'concepto,moneda,monto,fecha,pesos,tipo_op,editor,activo,id_host');
        $monedaOutput = array('£', 'U$D');
        $htm = '<li id="rowNro' . $idCreated . '" class="row rowAdded">
				<p class="tableConcepto">
					' . $concepto . '
					<span class="tableFecha">' . date('d-m-Y') . '</span>
				</p>
				<span class="tableMonto tipo_op' . $tipo_op . '"><span class="fontMoneda' . $moneda . '">' . $monedaOutput[$moneda] . '</span> ' . $monto . '</span>
				<span class="tableOpciones">
					<a class="modifyOpTable" href="javascript:;" onClick="toggleEditor(5,' . $idCreated . ',\'' . str_replace("'", "\\'", $concepto) . '\',\'' . $monto . '\',' . $moneda . ',' . $tipo_op . ')">&nbsp;</a>
		<a class="deleteOpTable" href="javascript:;" onClick="delPayment(\'payment\',' . $idCreated . ',\'' . str_replace("'", "\\'", $concepto) . '\',0)">&nbsp;</a>
				</span>
			</li>';
        return $htm;
    }
开发者ID:richiramone,项目名称:Labs,代码行数:35,代码来源:gastos-functions.php

示例8: add

    public function add($concepto, $moneda, $monto, $tipo_op)
    {
        include_once '../db.php';
        $db = new Database();
        $db->connect();
        $valores = array();
        $valores[0] = '"' . $concepto . '"';
        $valores[1] = $moneda;
        $valores[2] = $monto;
        $valores[3] = '"' . date('Y-m-d') . '"';
        $valores[4] = $monto;
        $valores[5] = $tipo_op;
        $valores[6] = '"pepe"';
        $valores[7] = 1;
        $valores[8] = 0;
        if ($moneda == 1) {
            $dolar = new dolar();
            $dolarCompra = $dolar->getDolar();
            $valores[4] = round($monto * $dolarCompra, 2);
        }
        $idCreated = $db->insert('pagos', $valores, 'concepto,moneda,monto,fecha,pesos,tipo_op,editor,activo,id_host');
        $monedaOutput = array('£', 'U$D');
        $htm = '<li id="rowNro' . $idCreated . '" class="row rowAdded">
					<span class="col1">' . date('d-m-Y') . '</span>
					<span class="col2">' . $concepto . '</span>
					<span class="col3 tipo_op' . $tipo_op . '">' . $monedaOutput[$moneda] . ' ' . $monto . '</span>
					<span class="col4">
						<a class="modifyOpTable" href="javascript:;" onClick="showModGastos(' . $idCreated . ',\'' . str_replace("'", "\\'", $concepto) . '\',\'' . $monto . '\',' . $moneda . ',' . $tipo_op . ')">&nbsp;</a>
                    	<a class="deleteOpTable" href="javascript:;" onClick="gastos(\'del\',' . $idCreated . ',\'' . str_replace("'", "\\'", $concepto) . '\')">&nbsp;</a>
					</span>
				</li>
				';
        return $htm;
    }
开发者ID:richiramone,项目名称:Labs,代码行数:34,代码来源:gastos-functions.php

示例9: bulk_verify

 /**
  * Provides the services/data_utils/bulk_verify service. This takes a report plus params (json object) in the $_POST
  * data and verifies all the records returned by the report according to the filter. Pass ignore=true to allow this to 
  * ignore any verification check rule failures (use with care!).
  */
 public function bulk_verify()
 {
     $db = new Database();
     $this->authenticate('write');
     $report = $_POST['report'];
     $params = json_decode($_POST['params'], true);
     $params['sharing'] = 'verification';
     $websites = $this->website_id ? array($this->website_id) : null;
     $this->reportEngine = new ReportEngine($websites, $this->user_id);
     try {
         // Load the report used for the verification grid with the same params
         $data = $this->reportEngine->requestReport("{$report}.xml", 'local', 'xml', $params);
         // now get a list of all the occurrence ids
         $ids = array();
         foreach ($data['content']['records'] as $record) {
             if ($record['record_status'] !== 'V' && (!empty($record['pass']) || $_POST['ignore'] === 'true')) {
                 $ids[$record['occurrence_id']] = $record['occurrence_id'];
                 $db->insert('occurrence_comments', array('occurrence_id' => $record['occurrence_id'], 'comment' => 'This record is assumed to be correct', 'created_by_id' => $this->user_id, 'created_on' => date('Y-m-d H:i:s'), 'updated_by_id' => $this->user_id, 'updated_on' => date('Y-m-d H:i:s')));
             }
         }
         $db->from('occurrences')->set(array('record_status' => 'V', 'verified_by_id' => $this->user_id, 'verified_on' => date('Y-m-d H:i:s'), 'updated_by_id' => $this->user_id, 'updated_on' => date('Y-m-d H:i:s')))->in('id', array_keys($ids))->update();
         echo count($ids);
         $db->from('cache_occurrences')->set(array('record_status' => 'V', 'cache_updated_on' => date('Y-m-d H:i:s')))->in('id', array_keys($ids))->update();
     } catch (Exception $e) {
         echo $e->getMessage();
         error::log_error('Exception during bulk verify', $e);
     }
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:33,代码来源:data_utils.php

示例10: updateDependencyList

 /**
  * @since 2.3
  *
  * @param integer $sid
  * @param array $dependencyList
  */
 public function updateDependencyList($sid, array $dependencyList)
 {
     $this->connection->beginAtomicTransaction(__METHOD__);
     // Before an insert, delete all entries that for the criteria which is
     // cheaper then doing an individual upsert or selectRow, this also ensures
     // that entries are self-corrected for dependencies matched
     $this->connection->delete(SMWSQLStore3::QUERY_LINKS_TABLE, array('s_id' => $sid), __METHOD__);
     if ($sid == 0) {
         return $this->connection->endAtomicTransaction(__METHOD__);
     }
     $inserts = array();
     foreach ($dependencyList as $dependency) {
         $oid = $this->getIdForSubject($dependency);
         if ($oid < 1) {
             continue;
         }
         $inserts[$sid . $oid] = array('s_id' => $sid, 'o_id' => $oid);
     }
     if ($inserts === array()) {
         return $this->connection->endAtomicTransaction(__METHOD__);
     }
     // MW's multi-array insert needs a numeric dimensional array but the key
     // was used with a hash to avoid duplicate entries hence the re-copy
     $inserts = array_values($inserts);
     wfDebugLog('smw', __METHOD__ . ' insert for SID ' . $sid . "\n");
     $this->connection->insert(SMWSQLStore3::QUERY_LINKS_TABLE, $inserts, __METHOD__);
     $this->connection->endAtomicTransaction(__METHOD__);
 }
开发者ID:kimcollin,项目名称:SemanticMediaWiki,代码行数:34,代码来源:EmbeddedQueryDependencyLinksStore.php

示例11: add

	public function add ($query) {

		list($place, $item_id) = $this->parse_referer($query);

		if (!empty($query['parent'])) {
			$root = Database::get_field('comment', 'root', $query['parent']);

			if (empty($root)) {
				$root = $query['parent'];
			}
		} else {
			$root = 0;
		}

		$insert = array(
			'root' => $root,
			'parent' => $query['parent'],
			'place' => $place,
			'item_id' => $item_id,
			'area' => 'main',
			'username' => $query['name'],
			'email' => $query['email'],
			'ip' => Globals::$user_data['ip'],
			'cookie' => Globals::$user_data['cookie'],
			'text' => Transform_Text::format($query['text']),
			'pretty_text' => $query['text'],
		);

		Database::insert('comment', $insert);
		
		Database::update($place, $item_id, array('comments' => '++'));

		$this->redirect_address = $this->referer;
	}
开发者ID:4otaku,项目名称:draw,代码行数:34,代码来源:input.php

示例12: copyExactMatch

 function copyExactMatch($srcTable, $dstTable, $copyPos)
 {
     $numRowsCopied = 0;
     $srcRes = $this->dbw->select($srcTable, '*', ['log_timestamp' => $copyPos], __METHOD__);
     $dstRes = $this->dbw->select($dstTable, '*', ['log_timestamp' => $copyPos], __METHOD__);
     if ($srcRes->numRows()) {
         $srcRow = $srcRes->fetchObject();
         $srcFields = array_keys((array) $srcRow);
         $srcRes->seek(0);
         $dstRowsSeen = [];
         # Make a hashtable of rows that already exist in the destination
         foreach ($dstRes as $dstRow) {
             $reducedDstRow = [];
             foreach ($srcFields as $field) {
                 $reducedDstRow[$field] = $dstRow->{$field};
             }
             $hash = md5(serialize($reducedDstRow));
             $dstRowsSeen[$hash] = true;
         }
         # Copy all the source rows that aren't already in the destination
         foreach ($srcRes as $srcRow) {
             $hash = md5(serialize((array) $srcRow));
             if (!isset($dstRowsSeen[$hash])) {
                 $this->dbw->insert($dstTable, (array) $srcRow, __METHOD__);
                 $numRowsCopied++;
             }
         }
     }
     return $numRowsCopied;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:30,代码来源:upgradeLogging.php

示例13: updateDependencyList

 /**
  * @since 2.3
  *
  * @param integer $sid
  * @param array $dependencyList
  */
 public function updateDependencyList($sid, array $dependencyList)
 {
     $this->connection->beginAtomicTransaction(__METHOD__);
     // Before an insert, delete all entries that for the criteria which is
     // cheaper then doing an individual upsert or selectRow, this also ensures
     // that entries are self-corrected for dependencies matched
     $this->connection->delete(SMWSQLStore3::QUERY_LINKS_TABLE, array('s_id' => $sid), __METHOD__);
     if ($sid == 0) {
         return $this->connection->endAtomicTransaction(__METHOD__);
     }
     $inserts = array();
     foreach ($dependencyList as $dependency) {
         $oid = $this->getIdForSubject($dependency);
         // If the ID_TABLE didn't contained an valid ID then we create one ourselves
         // to ensure that object entities are tracked from the start
         // This can happen when a query is added with object reference that have not
         // yet been referenced as annotation and therefore do not recognized as
         // value annotation
         if ($oid < 1 && ($oid = $this->tryToMakeIdForSubject($dependency)) < 1) {
             continue;
         }
         $inserts[$sid . $oid] = array('s_id' => $sid, 'o_id' => $oid);
     }
     if ($inserts === array()) {
         return $this->connection->endAtomicTransaction(__METHOD__);
     }
     // MW's multi-array insert needs a numeric dimensional array but the key
     // was used with a hash to avoid duplicate entries hence the re-copy
     $inserts = array_values($inserts);
     wfDebugLog('smw', __METHOD__ . ' insert for SID ' . $sid . "\n");
     $this->connection->insert(SMWSQLStore3::QUERY_LINKS_TABLE, $inserts, __METHOD__);
     $this->connection->endAtomicTransaction(__METHOD__);
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:39,代码来源:EmbeddedQueryDependencyLinksStore.php

示例14: createRoom

 /**
  * Create a video chat
  * @param int $fromUser The sender user
  * @param int $toUser The receiver user
  * @return int The created video chat id. Otherwise return false
  */
 public static function createRoom($fromUser, $toUser)
 {
     $fromUserInfo = api_get_user_info($fromUser);
     $toUserInfo = api_get_user_info($toUser);
     $chatName = vsprintf(get_lang('VideoChatBetweenUserXAndUserY'), [$fromUserInfo['firstname'], $toUserInfo['firstname']]);
     return Database::insert(Database::get_main_table(TABLE_MAIN_CHAT_VIDEO), ['from_user' => intval($fromUser), 'to_user' => intval($toUser), 'room_name' => $chatName, 'datetime' => api_get_utc_datetime()]);
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:13,代码来源:VideoChat.php

示例15: process

 public function process(array $documents, &$context)
 {
     $doc = $documents[self::URL_HISTORY];
     $dom = self::getDOM($doc);
     $xpath = new DOMXPath($dom);
     Database::delete('userhistory', ['user_id' => $context->user->id]);
     $data = [];
     $nodes = $xpath->query('//table//td[@class = \'borderClass\']/..');
     foreach ($nodes as $node) {
         //basic info
         $link = $node->childNodes->item(0)->childNodes->item(0)->getAttribute('href');
         preg_match('/(\\d+)\\/?$/', $link, $matches);
         $media = strpos($link, 'manga') !== false ? Media::Manga : Media::Anime;
         $mediaMalId = intval($matches[0]);
         $progress = Strings::makeInteger($node->childNodes->item(0)->childNodes->item(2)->nodeValue);
         //parse time
         //That's what MAL servers output for MG client
         if (isset($doc->headers['Date'])) {
             date_default_timezone_set('UTC');
             $now = strtotime($doc->headers['Date']);
         } else {
             $now = time();
         }
         date_default_timezone_set('America/Los_Angeles');
         $hour = date('H', $now);
         $minute = date('i', $now);
         $second = date('s', $now);
         $day = date('d', $now);
         $month = date('m', $now);
         $year = date('Y', $now);
         $dateString = $node->childNodes->item(2)->nodeValue;
         if (preg_match('/(\\d*) seconds? ago/', $dateString, $matches)) {
             $second -= intval($matches[1]);
         } elseif (preg_match('/(\\d*) minutes? ago/', $dateString, $matches)) {
             $second -= intval($matches[1]) * 60;
         } elseif (preg_match('/(\\d*) hours? ago/', $dateString, $matches)) {
             $minute -= intval($matches[1]) * 60;
         } elseif (preg_match('/Today, (\\d*):(\\d\\d) (AM|PM)/', $dateString, $matches)) {
             $hour = intval($matches[1]);
             $minute = intval($matches[2]);
             $hour += ($matches[3] == 'PM' and $hour != 12) ? 12 : 0;
         } elseif (preg_match('/Yesterday, (\\d*):(\\d\\d) (AM|PM)/', $dateString, $matches)) {
             $hour = intval($matches[1]);
             $minute = intval($matches[2]);
             $hour += ($matches[3] == 'PM' and $hour != 12) ? 12 : 0;
             $hour -= 24;
         } elseif (preg_match('/(\\d\\d)-(\\d\\d)-(\\d\\d), (\\d*):(\\d\\d) (AM|PM)/', $dateString, $matches)) {
             $year = intval($matches[3]) + 2000;
             $month = intval($matches[1]);
             $day = intval($matches[2]);
             $hour = intval($matches[4]);
             $minute = intval($matches[5]);
             $hour += ($matches[6] == 'PM' and $hour != 12) ? 12 : 0;
         }
         $timestamp = mktime($hour, $minute, $second, $month, $day, $year);
         date_default_timezone_set('UTC');
         $data[] = ['user_id' => $context->user->id, 'mal_id' => $mediaMalId, 'media' => $media, 'progress' => $progress, 'timestamp' => date('Y-m-d H:i:s', $timestamp)];
     }
     Database::insert('userhistory', $data);
 }
开发者ID:BrokenSilence,项目名称:malgraph4,代码行数:60,代码来源:UserSubProcessorHistory.php


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