本文整理汇总了PHP中TYPO3\CMS\Core\Database\DatabaseConnection::UPDATEquery方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection::UPDATEquery方法的具体用法?PHP DatabaseConnection::UPDATEquery怎么用?PHP DatabaseConnection::UPDATEquery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Database\DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::UPDATEquery方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateIdentifierHashesForStorage
/**
* Creates file identifier hashes for a single storage.
*
* @param ResourceStorage $storage The storage to update
* @return array The executed database queries
*/
protected function updateIdentifierHashesForStorage(ResourceStorage $storage)
{
$queries = array();
if (!ExtensionManagementUtility::isLoaded('dbal')) {
// if DBAL is not loaded, we're using MySQL and can thus use their
// SHA1() function
if ($storage->usesCaseSensitiveIdentifiers()) {
$updateCall = 'SHA1(identifier)';
} else {
$updateCall = 'SHA1(LOWER(identifier))';
}
$queries[] = $query = sprintf('UPDATE sys_file SET identifier_hash = %s WHERE storage=%d', $updateCall, $storage->getUid());
$this->db->sql_query($query);
// folder hashes cannot be done with one call: so do it manually
$files = $this->db->exec_SELECTgetRows('uid, storage, identifier', 'sys_file', sprintf('storage=%d AND folder_hash=""', $storage->getUid()));
foreach ($files as $file) {
$folderHash = $storage->hashFileIdentifier($storage->getFolderIdentifierFromFileIdentifier($file['identifier']));
$queries[] = $query = $this->db->UPDATEquery('sys_file', 'uid=' . $file['uid'], array('folder_hash' => $folderHash));
$this->db->sql_query($query);
}
} else {
// manually hash the identifiers when using DBAL
$files = $this->db->exec_SELECTgetRows('uid, storage, identifier', 'sys_file', sprintf('storage=%d AND identifier_hash=""', $storage->getUid()));
foreach ($files as $file) {
$hash = $storage->hashFileIdentifier($file['identifier']);
$folderHash = $storage->hashFileIdentifier($storage->getFolderIdentifierFromFileIdentifier($file['identifier']));
$queries[] = $query = $this->db->UPDATEquery('sys_file', 'uid=' . $file['uid'], array('identifier_hash' => $hash, 'folder_hash' => $folderHash));
$this->db->sql_query($query);
}
}
return $queries;
}
示例2: updateQueryCreateValidQuery
/**
* @test
*
* @return void
*/
public function updateQueryCreateValidQuery()
{
$this->subject = $this->getAccessibleMock(DatabaseConnection::class, ['fullQuoteStr'], [], '', false);
$this->subject->expects($this->any())->method('fullQuoteStr')->will($this->returnCallback(function ($data) {
return '\'' . (string) $data . '\'';
}));
$fieldsValues = [$this->testField => 'aTestValue'];
$queryExpected = "UPDATE {$this->testTable} SET {$this->testField}='aTestValue' WHERE id=1";
$queryGenerated = $this->subject->UPDATEquery($this->testTable, 'id=1', $fieldsValues);
$this->assertSame($queryExpected, $queryGenerated);
}
示例3: dbUpdate
/**
* Db update object
*
* @param int $uid Uid
* @param Tx_Commerce_Dao_BasicDaoObject $object Object
*
* @return void
*/
protected function dbUpdate($uid, Tx_Commerce_Dao_BasicDaoObject &$object)
{
$dbTable = $this->dbTable;
$dbWhere = 'uid = ' . (int) $uid;
$dbModel = $this->parser->parseObjectToModel($object);
// execute query
$this->database->exec_UPDATEquery($dbTable, $dbWhere, $dbModel);
// any errors
$error = $this->database->sql_error();
if (!empty($error)) {
$this->addError(array($error, $this->database->UPDATEquery($dbTable, $dbWhere, $dbModel), '$dbModel' => $dbModel));
}
}
示例4: updateOutdatedContentFlexForm
/**
* Updates the FlexForm data in the given outdated content element.
*
* @param array $outdatedContent
* @param array &$dbQueries Queries done in this update
*/
protected function updateOutdatedContentFlexForm($outdatedContent, array &$dbQueries)
{
$flexFormArray = GeneralUtility::xml2array($outdatedContent['pi_flexform']);
if (isset($flexFormArray['data']['rss']['lDEF']['settings.list.rss.channel'])) {
$title = $flexFormArray['data']['rss']['lDEF']['settings.list.rss.channel'];
unset($flexFormArray['data']['rss']['lDEF']['settings.list.rss.channel']);
$flexFormArray['data']['rss']['lDEF']['settings.list.rss.channel.title'] = $title;
}
$flexFormData = $this->flexObj->flexArray2Xml($flexFormArray);
$query = $this->db->UPDATEquery('tt_content', 'uid=' . (int) $outdatedContent['uid'], array('pi_flexform' => $flexFormData));
$this->db->sql_query($query);
$dbQueries[] = $query;
}
示例5: getQueriesToEncryptOldBounceAccountPasswords
/**
* Encrypt old bounce account passwords and preserve old default config
*
* @return string[]
*/
private function getQueriesToEncryptOldBounceAccountPasswords()
{
// Fetch the old records - they will have a default port and an empty config.
$rs = $this->databaseConnection->exec_SELECTquery('uid, password', 'tx_newsletter_domain_model_bounceaccount', 'port = 0 AND config = \'\'');
$records = [];
while ($record = $this->databaseConnection->sql_fetch_assoc($rs)) {
$records[] = $record;
}
$this->databaseConnection->sql_free_result($rs);
if (empty($records)) {
return [];
}
// Keep the old config to not break old installations
$config = Tools::encrypt("poll ###SERVER###\nproto ###PROTOCOL### \nusername \"###USERNAME###\"\npassword \"###PASSWORD###\"\n");
$queries = [];
foreach ($records as $record) {
$queries[] = $this->databaseConnection->UPDATEquery('tx_newsletter_domain_model_bounceaccount', 'uid=' . intval($record['uid']), ['password' => Tools::encrypt($record['password']), 'config' => $config]);
}
return ['Encrypt bounce account passwords' => $queries];
}
示例6: returnLastBuiltUpdateQuery
/**
* Returns the last built SQL UPDATE query with tabs removed.
*
* This function tries to retrieve the last built SQL UPDATE query from the database object property $this->debug_lastBuiltQuery (works only since T3 3.8.0 with $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = true). If this does not succeed, a fallback method is used (for former versions of class.\TYPO3\CMS\Core\Database\DatabaseConnection.php [TYPO3 3.6.0-3.8.0beta1] or $GLOBALS['TYPO3_DB']->store_lastBuiltQuery _not_ set to true) to retrieve the query string from \TYPO3\CMS\Core\Database\DatabaseConnection::UPDATEquery() - as this is an overhead (\TYPO3\CMS\Core\Database\DatabaseConnection::UPDATEquery() is called a second time after the call from \TYPO3\CMS\Core\Database\DatabaseConnection::exec_UPDATE_query) IMO this should not be a permanent solution.
*
* @param DatabaseConnection TYPO3 database object (instance of \TYPO3\CMS\Core\Database\DatabaseConnection) used for last executed SQL query
* @param string table name passed to last executed SQL query (see comment of \TYPO3\CMS\Core\Database\DatabaseConnection::exec_UPDATEquery())
* @param string where clause passed to last executed SQL query (see comment of \TYPO3\CMS\Core\Database\DatabaseConnection::exec_UPDATEquery())
* @param array array containing field/value-pairs passed to last executed SQL query (see comment of \TYPO3\CMS\Core\Database\DatabaseConnection::exec_UPDATEquery())
* @return string last built SQL query with tabs removed
* @see class.\TYPO3\CMS\Core\Database\DatabaseConnection.php, \TYPO3\CMS\Core\Database\DatabaseConnection::exec_UPDATEquery()
* @author Rainer Kuhn
*/
public static function returnLastBuiltUpdateQuery(DatabaseConnection $dbObject, $table, $where, $updateFieldsArr)
{
// try to get query from debug_lastBuiltQuery (works only for T3 3.8.0 with $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = true)
$query = $dbObject->debug_lastBuiltQuery;
// fallback for former versions of class.\TYPO3\CMS\Core\Database\DatabaseConnection.php (TYPO3 3.6.0-3.8.0beta1) or $GLOBALS['TYPO3_DB']->store_lastBuiltQuery _not_ set to true
if (strlen($query) < 1) {
$query = $dbObject->UPDATEquery($table, $where, $updateFieldsArr);
}
// remove tabs and return query string
return str_replace(chr(9), '', $query);
}