本文整理汇总了PHP中TYPO3\CMS\Core\Database\DatabaseConnection::exec_INSERTquery方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection::exec_INSERTquery方法的具体用法?PHP DatabaseConnection::exec_INSERTquery怎么用?PHP DatabaseConnection::exec_INSERTquery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Database\DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::exec_INSERTquery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createRecords
/**
* creates an image record for each image which was selected in the select-box
*/
private function createRecords()
{
$url = $this->feedImport['feed_url'];
// TODO: import image from media feed
//$fileNames = explode(',', );
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($data, LIBXML_NOCDATA);
$maxImages = 5;
foreach ($xml->channel[0]->item as $item) {
$mediaProperties = $item->children('http://search.yahoo.com/mrss/');
$mediaContent = $mediaProperties->content[0];
$imageUrl = $mediaContent->attributes()->url;
$fileName = $this->getFilenameFromUrl($imageUrl);
if (trim($fileName) && !isset($this->images[$fileName])) {
$filepath = PATH_site . 'uploads/tx_gorillary/' . $fileName;
$this->downloadFile($imageUrl, $filepath);
$newRecord = array('pid' => $this->feedImport['pid'], 'feedimport' => $this->feedImport['uid'], 'crdate' => time(), 'cruser_id' => $this->feedImport['cruser_id'], 'image' => $fileName, 'title' => trim($item->title), 'description' => trim($item->description), 'link' => $item->link);
$this->db->exec_INSERTquery('tx_gorillary_images', $newRecord);
$newRecord['uid'] = $this->db->sql_insert_id();
$this->images[$fileName] = $newRecord;
}
$maxImages--;
if ($maxImages == 0) {
break;
}
}
}
示例2: storedGzipCompressedDataReturnsSameData
/**
* @test
*/
public function storedGzipCompressedDataReturnsSameData()
{
$testStringWithBinary = @gzcompress('sdfkljer4587');
$this->fixture->exec_INSERTquery($this->testTable, array('fieldblob' => $testStringWithBinary));
$id = $this->fixture->sql_insert_id();
$entry = $this->fixture->exec_SELECTgetRows('fieldblob', $this->testTable, 'id = ' . $id);
$this->assertEquals($testStringWithBinary, $entry[0]['fieldblob']);
}
示例3: createRecords
/**
* creates an image record for each image which was selected in the select-box
*/
private function createRecords()
{
$fileNames = explode(',', $this->collection['images']);
foreach ($fileNames as $fileName) {
if (trim($fileName) && !isset($this->images[$fileName])) {
$newRecord = array('pid' => $this->collection['pid'], 'collection' => $this->collection['uid'], 'crdate' => time(), 'cruser_id' => $this->collection['cruser_id'], 'image' => $fileName, 'title' => $this->getTitleFromName($fileName));
$this->db->exec_INSERTquery('tx_gorillary_images', $newRecord);
$newRecord['uid'] = $this->db->sql_insert_id();
$this->images[$fileName] = $newRecord;
}
}
}
示例4: migrateDamReferencesToFalReferences
/**
* Migrate dam references to fal references
*
* @param \mysqli_result $result
* @param string $table
* @param string $type
* @param array $fieldnameMapping Re-map fieldnames e.g.
* tx_damnews_dam_images => tx_falttnews_fal_images
*
* @return void
*/
protected function migrateDamReferencesToFalReferences($result, $table, $type, $fieldnameMapping = array())
{
$counter = 0;
$total = $this->database->sql_num_rows($result);
$this->controller->infoMessage('Found ' . $total . ' ' . $table . ' records with a dam ' . $type);
while ($record = $this->database->sql_fetch_assoc($result)) {
$identifier = $this->getFullFileName($record);
try {
$fileObject = $this->storageObject->getFile($identifier);
} catch (\Exception $e) {
// If file is not found
// getFile will throw an invalidArgumentException if the file
// does not exist. Create an empty file to avoid this. This is
// usefull in a development environment that has the production
// database but not all the physical files.
try {
GeneralUtility::mkdir_deep(PATH_site . $this->storageBasePath . dirname($identifier));
} catch (\Exception $e) {
$this->controller->errorMessage('Unable to create directory: ' . PATH_site . $this->storageBasePath . $identifier);
continue;
}
$config = $this->controller->getConfiguration();
if (isset($config['createMissingFiles']) && (int) $config['createMissingFiles']) {
$this->controller->infoMessage('Creating empty missing file: ' . PATH_site . $this->storageBasePath . $identifier);
try {
GeneralUtility::writeFile(PATH_site . $this->storageBasePath . $identifier, '');
} catch (\Exception $e) {
$this->controller->errorMessage('Unable to create file: ' . PATH_site . $this->storageBasePath . $identifier);
continue;
}
} else {
$this->controller->errorMessage('File not found: ' . PATH_site . $this->storageBasePath . $identifier);
continue;
}
$fileObject = $this->storageObject->getFile($identifier);
}
if ($fileObject instanceof \TYPO3\CMS\Core\Resource\File) {
if ($fileObject->isMissing()) {
$this->controller->warningMessage('FAL did not find any file resource for DAM record. DAM uid: ' . $record['uid'] . ': "' . $identifier . '"');
continue;
}
$record['uid_local'] = $fileObject->getUid();
foreach ($fieldnameMapping as $old => $new) {
if ($record['ident'] === $old) {
$record['ident'] = $new;
}
}
$progress = number_format(100 * ($counter++ / $total), 1) . '% of ' . $total;
if (!$this->doesFileReferenceExist($record)) {
$insertData = array('tstamp' => time(), 'crdate' => time(), 'cruser_id' => $GLOBALS['BE_USER']->user['uid'], 'uid_local' => $record['uid_local'], 'uid_foreign' => (int) $record['uid_foreign'], 'sorting' => (int) $record['sorting'], 'sorting_foreign' => (int) $record['sorting_foreign'], 'tablenames' => (string) $record['tablenames'], 'fieldname' => (string) $record['ident'], 'table_local' => 'sys_file', 'pid' => $record['item_pid'], 'l10n_diffsource' => (string) $record['l18n_diffsource']);
$this->database->exec_INSERTquery('sys_file_reference', $insertData);
$this->amountOfMigratedRecords++;
$this->controller->message($progress . ' Migrating relation for ' . (string) $record['tablenames'] . ' uid: ' . $record['item_uid'] . ' dam uid: ' . $record['dam_uid'] . ' to fal uid: ' . $record['uid_local']);
} else {
$this->controller->message($progress . ' Reference already exists for uid: ' . (int) $record['item_uid']);
}
}
}
$this->database->sql_free_result($result);
}
示例5: getmypid
/**
* Try to acquire a new process with the given id
* also performs some auto-cleanup for orphan processes
* @todo preemption might not be the most elegant way to clean up
*
* @param string $id identification string for the process
* @return boolean determines whether the attempt to get resources was successful
*/
function CLI_checkAndAcquireNewProcess($id)
{
$ret = true;
$systemProcessId = getmypid();
if ($systemProcessId < 1) {
return FALSE;
}
$processCount = 0;
$orphanProcesses = array();
$this->db->sql_query('BEGIN');
$res = $this->db->exec_SELECTquery('process_id,ttl', 'tx_crawler_process', 'active=1 AND deleted=0');
$currentTime = $this->getCurrentTime();
while ($row = $this->db->sql_fetch_assoc($res)) {
if ($row['ttl'] < $currentTime) {
$orphanProcesses[] = $row['process_id'];
} else {
$processCount++;
}
}
// if there are less than allowed active processes then add a new one
if ($processCount < intval($this->extensionSettings['processLimit'])) {
$this->CLI_debug("add " . $this->CLI_buildProcessId() . " (" . ($processCount + 1) . "/" . intval($this->extensionSettings['processLimit']) . ")");
// create new process record
$this->db->exec_INSERTquery('tx_crawler_process', array('process_id' => $id, 'active' => '1', 'ttl' => $currentTime + intval($this->extensionSettings['processMaxRunTime']), 'system_process_id' => $systemProcessId));
} else {
$this->CLI_debug("Processlimit reached (" . $processCount . "/" . intval($this->extensionSettings['processLimit']) . ")");
$ret = false;
}
$this->CLI_releaseProcesses($orphanProcesses, true);
// maybe this should be somehow included into the current lock
$this->CLI_deleteProcessesMarkedDeleted();
$this->db->sql_query('COMMIT');
return $ret;
}
示例6: migrateCategoryImages
/**
* Migrate news_category.image (CSV) to sys_category.images (sys_file_reference)
*
* @return void
*/
protected function migrateCategoryImages()
{
$oldCategories = $this->databaseConnection->exec_SELECTgetRows('uid, pid, image, migrate_sys_category_uid', 'tx_news_domain_model_category', 'deleted=0 AND image!=""');
// no images to process then skip
if (!count($oldCategories)) {
return;
}
$processedImages = 0;
foreach ($oldCategories as $oldCategory) {
$files = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $oldCategory['image'], true);
$i = 0;
foreach ($files as $file) {
if (file_exists(PATH_site . 'uploads/tx_news/' . $file)) {
$fileObject = $this->getCategoryImageFolder()->addFile(PATH_site . 'uploads/tx_news/' . $file);
$dataArray = array('uid_local' => $fileObject->getUid(), 'tstamp' => $_SERVER['REQUEST_TIME'], 'crdate' => $_SERVER['REQUEST_TIME'], 'tablenames' => 'sys_category', 'uid_foreign' => $oldCategory['migrate_sys_category_uid'], 'pid' => $oldCategory['pid'], 'fieldname' => 'images', 'table_local' => 'sys_file', 'sorting_foreign' => $i);
$this->databaseConnection->exec_INSERTquery('sys_file_reference', $dataArray);
$processedImages++;
}
$i++;
}
}
$message = 'Migrated ' . $processedImages . ' category images';
$status = FlashMessage::INFO;
$title = '';
$this->messageArray[] = array($status, $title, $message);
}
示例7: storeNewAssociation
/**
* Stores new association to the database.
*
* @param string $serverUrl Server URL
* @param \Auth_OpenID_Association $association OpenID association
* @return void
*/
protected function storeNewAssociation($serverUrl, $association)
{
$serializedAssociation = serialize($association);
$values = array('assoc_handle' => $association->handle, 'content' => base64_encode($serializedAssociation), 'crdate' => $association->issued, 'tstamp' => time(), 'expires' => $association->issued + $association->lifetime - self::ASSOCIATION_EXPIRATION_SAFETY_INTERVAL, 'server_url' => $serverUrl);
// In the next query we can get race conditions. sha1_hash prevents many
// asociations from being stored for one server
$this->databaseConnection->exec_INSERTquery(self::ASSOCIATION_TABLE_NAME, $values);
}
示例8: createPostSysFileReference
/**
* Add new sys_file_reference for the preview image
*
* @param FileReference $fileObject
* @param array $postRecord
*
* @return void
*/
protected function createPostSysFileReference(FileReference $fileObject, $postRecord)
{
if (!$fileObject instanceof FileReference) {
return;
}
$dataArray = array('uid_local' => $fileObject->getOriginalFile()->getUid(), 'tablenames' => 'tx_t3blog_post', 'fieldname' => 'preview_image', 'uid_foreign' => $postRecord['uid'], 'table_local' => 'sys_file', 'cruser_id' => 999, 'pid' => $postRecord['pid']);
$this->databaseConnection->exec_INSERTquery('sys_file_reference', $dataArray);
$this->logDatabaseExec();
}
示例9: putUrlToCache
/**
* Sets the entry to cache.
*
* @param UrlCacheEntry $cacheEntry
* @return void
*/
public function putUrlToCache(UrlCacheEntry $cacheEntry)
{
$data = array('original_url' => $cacheEntry->getOriginalUrl(), 'page_id' => $cacheEntry->getPageId(), 'request_variables' => json_encode($cacheEntry->getRequestVariables()), 'rootpage_id' => $cacheEntry->getRootPageId(), 'speaking_url' => $cacheEntry->getSpeakingUrl());
if ($cacheEntry->getCacheId()) {
$this->databaseConnection->exec_UPDATEquery('tx_realurl_urlcache', 'uid=' . $this->databaseConnection->fullQuoteStr($cacheEntry->getCacheId(), 'tx_realurl_urlcache'), $data);
} else {
$this->databaseConnection->exec_INSERTquery('tx_realurl_urlcache', $data);
$cacheEntry->setCacheId($this->databaseConnection->sql_insert_id());
}
}
示例10: prepareTables
/**
* Add is_dummy_record record and create dummy record
*
* @return void
*/
private function prepareTables()
{
$sql = 'ALTER TABLE %s ADD is_dummy_record tinyint(1) unsigned DEFAULT \'0\' NOT NULL';
foreach ($this->tables as $table) {
$_sql = sprintf($sql, $table);
$this->database->sql_query($_sql);
}
$values = array('title' => $this->getUniqueId('title'), 'l10n_diffsource' => '', 'description' => '', 'is_dummy_record' => 1);
$this->database->exec_INSERTquery('sys_category', $values);
$this->categoryUid = $this->database->sql_insert_id();
}
示例11: addRow
/**
* Adds a row to the storage
*
* @param string $tableName The database table name
* @param array $fieldValues The row to be inserted
* @param bool $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
* @return int The uid of the inserted row
*/
public function addRow($tableName, array $fieldValues, $isRelation = FALSE)
{
if (isset($fieldValues['uid'])) {
unset($fieldValues['uid']);
}
$this->databaseHandle->exec_INSERTquery($tableName, $fieldValues);
$this->checkSqlErrors();
$uid = $this->databaseHandle->sql_insert_id();
if (!$isRelation) {
$this->clearPageCache($tableName, $uid);
}
return (int) $uid;
}
示例12: createLocalStorage
/**
* Create the initial local storage base e.g. for the fileadmin/ directory.
*
* @param string $name
* @param string $basePath
* @param string $pathType
* @param string $description
* @param bool $default set to default storage
* @return int uid of the inserted record
*/
public function createLocalStorage($name, $basePath, $pathType, $description = '', $default = false)
{
$caseSensitive = $this->testCaseSensitivity($pathType === 'relative' ? PATH_site . $basePath : $basePath);
// create the FlexForm for the driver configuration
$flexFormData = array('data' => array('sDEF' => array('lDEF' => array('basePath' => array('vDEF' => rtrim($basePath, '/') . '/'), 'pathType' => array('vDEF' => $pathType), 'caseSensitive' => array('vDEF' => $caseSensitive)))));
/** @var $flexObj FlexFormTools */
$flexObj = GeneralUtility::makeInstance(FlexFormTools::class);
$flexFormXml = $flexObj->flexArray2Xml($flexFormData, true);
// create the record
$field_values = array('pid' => 0, 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME'], 'name' => $name, 'description' => $description, 'driver' => 'Local', 'configuration' => $flexFormXml, 'is_online' => 1, 'is_browsable' => 1, 'is_public' => 1, 'is_writable' => 1, 'is_default' => $default ? 1 : 0);
$this->db->exec_INSERTquery('sys_file_storage', $field_values);
return (int) $this->db->sql_insert_id();
}
示例13: add
/**
* Adds a processedfile object in the database
*
* @param ProcessedFile $processedFile
* @return void
*/
public function add($processedFile)
{
if ($processedFile->isPersisted()) {
$this->update($processedFile);
} else {
$insertFields = $processedFile->toArray();
$insertFields['crdate'] = $insertFields['tstamp'] = time();
$insertFields = $this->cleanUnavailableColumns($insertFields);
$this->databaseConnection->exec_INSERTquery($this->table, $insertFields);
$uid = $this->databaseConnection->sql_insert_id();
$processedFile->updateProperties(array('uid' => $uid));
}
}
示例14: logDownload
/**
* Log the access of the file
*
* @param integer|null $intFileSize
*/
protected function logDownload($intFileSize = null)
{
if ($this->isLoggingEnabled()) {
if (is_null($intFileSize)) {
$intFileSize = $this->fileSize;
}
$data_array = array('tstamp' => time(), 'file_name' => $this->file, 'file_size' => $intFileSize, 'user_id' => intval($this->feUserObj->user['uid']));
if (is_null($this->logRowUid)) {
$this->databaseConnection->exec_INSERTquery('tx_nawsecuredl_counter', $data_array);
$this->logRowUid = $this->databaseConnection->sql_insert_id();
} else {
$this->databaseConnection->exec_UPDATEquery('tx_nawsecuredl_counter', '`uid`=' . (int) $this->logRowUid, $data_array);
}
}
}
示例15: updateDatabase
/**
* Writes changes into database
*
* @return void
*/
public function updateDatabase()
{
if (!is_array($this->data)) {
return;
}
$diff = array_diff_assoc($this->data, $this->origData);
foreach ($diff as $key => $value) {
if (!isset($this->data[$key])) {
unset($diff[$key]);
}
}
if (!empty($diff)) {
$this->data['tstamp'] = $diff['tstamp'] = $GLOBALS['EXEC_TIME'];
if (intVal($this->data['uid']) > 0) {
$this->databaseHandle->exec_UPDATEquery($this->getTableName(), 'uid=' . $this->getUid(), $diff);
} else {
$this->data['crdate'] = $diff['crdate'] = $GLOBALS['EXEC_TIME'];
$this->databaseHandle->exec_INSERTquery($this->getTableName(), $diff);
$this->setUid($this->databaseHandle->sql_insert_id());
$this->data['uid'] = $this->getUid();
}
$this->origData = $this->data;
}
}