本文整理汇总了PHP中qsprintf函数的典型用法代码示例。如果您正苦于以下问题:PHP qsprintf函数的具体用法?PHP qsprintf怎么用?PHP qsprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qsprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildWhereClause
protected function buildWhereClause(AphrontDatabaseConnection $conn_r)
{
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf($conn_r, 'id IN (%Ld)', $this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf($conn_r, 'phid IN (%Ls)', $this->phids);
}
if ($this->emailAddresses !== null) {
$where[] = qsprintf($conn_r, 'emailAddress IN (%Ls)', $this->emailAddresses);
}
if ($this->verificationCodes !== null) {
$hashes = array();
foreach ($this->verificationCodes as $code) {
$hashes[] = PhabricatorHash::digestForIndex($code);
}
$where[] = qsprintf($conn_r, 'verificationHash IN (%Ls)', $hashes);
}
if ($this->authorPHIDs !== null) {
$where[] = qsprintf($conn_r, 'authorPHID IN (%Ls)', $this->authorPHIDs);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
}
示例2: buildWhereClauseParts
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn)
{
$where = parent::buildWhereClauseParts($conn);
if ($this->phids !== null) {
$where[] = qsprintf($conn, 'p.phid IN (%Ls)', $this->phids);
}
if ($this->ids !== null) {
$where[] = qsprintf($conn, 'p.id IN (%Ld)', $this->ids);
}
if ($this->repositoryPHIDs !== null) {
$where[] = qsprintf($conn, 'rpath.repositoryPHID IN (%Ls)', $this->repositoryPHIDs);
}
if ($this->ownerPHIDs !== null) {
$base_phids = $this->ownerPHIDs;
$projects = id(new PhabricatorProjectQuery())->setViewer($this->getViewer())->withMemberPHIDs($base_phids)->execute();
$project_phids = mpull($projects, 'getPHID');
$all_phids = array_merge($base_phids, $project_phids);
$where[] = qsprintf($conn, 'o.userPHID IN (%Ls)', $all_phids);
}
if (strlen($this->namePrefix)) {
// NOTE: This is a hacky mess, but this column is currently case
// sensitive and unique.
$where[] = qsprintf($conn, 'LOWER(p.name) LIKE %>', phutil_utf8_strtolower($this->namePrefix));
}
return $where;
}
示例3: buildWhereClauseComponents
protected function buildWhereClauseComponents(AphrontDatabaseConnection $conn_r)
{
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf($conn_r, 'xcomment.id IN (%Ld)', $this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf($conn_r, 'xcomment.phid IN (%Ls)', $this->phids);
}
if ($this->authorPHIDs !== null) {
$where[] = qsprintf($conn_r, 'xcomment.authorPHID IN (%Ls)', $this->authorPHIDs);
}
if ($this->transactionPHIDs !== null) {
$where[] = qsprintf($conn_r, 'xcomment.transactionPHID IN (%Ls)', $this->transactionPHIDs);
}
if ($this->isDeleted !== null) {
$where[] = qsprintf($conn_r, 'xcomment.isDeleted = %d', (int) $this->isDeleted);
}
if ($this->hasTransaction !== null) {
if ($this->hasTransaction) {
$where[] = qsprintf($conn_r, 'xcomment.transactionPHID IS NOT NULL');
} else {
$where[] = qsprintf($conn_r, 'xcomment.transactionPHID IS NULL');
}
}
return $where;
}
示例4: loadPackagesForPaths
private static function loadPackagesForPaths(PhabricatorRepository $repository, array $paths, $limit = 0)
{
$package = new PhabricatorOwnersPackage();
$path = new PhabricatorOwnersPath();
$conn = $package->establishConnection('r');
$repository_clause = qsprintf($conn, 'AND p.repositoryPHID = %s', $repository->getPHID());
$limit_clause = '';
if (!empty($limit)) {
$limit_clause = qsprintf($conn, 'LIMIT %d', $limit);
}
$data = queryfx_all($conn, 'SELECT pkg.id FROM %T pkg JOIN %T p ON p.packageID = pkg.id
WHERE p.path IN (%Ls) %Q ORDER BY LENGTH(p.path) DESC %Q', $package->getTableName(), $path->getTableName(), $paths, $repository_clause, $limit_clause);
$ids = ipull($data, 'id');
if (empty($ids)) {
return array();
}
$order = array();
foreach ($ids as $id) {
if (empty($order[$id])) {
$order[$id] = true;
}
}
$packages = $package->loadAllWhere('id in (%Ld)', array_keys($order));
$packages = array_select_keys($packages, array_keys($order));
return $packages;
}
示例5: buildWhereClauseParts
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn)
{
$where = parent::buildWhereClauseParts($conn);
if ($this->callerPHIDs !== null) {
$where[] = qsprintf($conn, 'callerPHID IN (%Ls)', $this->callerPHIDs);
}
if ($this->methods !== null) {
$where[] = qsprintf($conn, 'method IN (%Ls)', $this->methods);
}
if ($this->methodStatuses !== null) {
$statuses = array_fuse($this->methodStatuses);
$methods = id(new PhabricatorConduitMethodQuery())->setViewer($this->getViewer())->execute();
$method_names = array();
foreach ($methods as $method) {
$status = $method->getMethodStatus();
if (isset($statuses[$status])) {
$method_names[] = $method->getAPIMethodName();
}
}
if (!$method_names) {
throw new PhabricatorEmptyQueryException();
}
$where[] = qsprintf($conn, 'method IN (%Ls)', $method_names);
}
return $where;
}
示例6: buildWhereClauseParts
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn)
{
$where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) {
$where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf($conn, 'phid IN (%Ls)', $this->phids);
}
if ($this->objectPHIDs !== null) {
$where[] = qsprintf($conn, 'objectPHID IN (%Ls)', $this->objectPHIDs);
}
if ($this->keys !== null) {
$sql = array();
foreach ($this->keys as $key) {
$sql[] = qsprintf($conn, '(keyType = %s AND keyIndex = %s)', $key->getType(), $key->getHash());
}
$where[] = implode(' OR ', $sql);
}
if ($this->isActive !== null) {
if ($this->isActive) {
$where[] = qsprintf($conn, 'isActive = %d', 1);
} else {
$where[] = qsprintf($conn, 'isActive IS NULL');
}
}
return $where;
}
示例7: buildWhereClauseParts
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn)
{
$where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) {
$where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids);
}
if ($this->tokenResources !== null) {
$where[] = qsprintf($conn, 'tokenResource IN (%Ls)', $this->tokenResources);
}
if ($this->tokenTypes !== null) {
$where[] = qsprintf($conn, 'tokenType IN (%Ls)', $this->tokenTypes);
}
if ($this->expired !== null) {
if ($this->expired) {
$where[] = qsprintf($conn, 'tokenExpires <= %d', time());
} else {
$where[] = qsprintf($conn, 'tokenExpires > %d', time());
}
}
if ($this->tokenCodes !== null) {
$where[] = qsprintf($conn, 'tokenCode IN (%Ls)', $this->tokenCodes);
}
if ($this->userPHIDs !== null) {
$where[] = qsprintf($conn, 'userPHID IN (%Ls)', $this->userPHIDs);
}
return $where;
}
示例8: buildWhereClause
protected function buildWhereClause($conn_r)
{
$where = array();
if ($this->ids) {
$where[] = qsprintf($conn_r, 'id IN (%Ld)', $this->ids);
}
if ($this->phids) {
$where[] = qsprintf($conn_r, 'phid IN (%Ls)', $this->phids);
}
if ($this->rangeBegin) {
$where[] = qsprintf($conn_r, 'dateTo >= %d', $this->rangeBegin);
}
if ($this->rangeEnd) {
$where[] = qsprintf($conn_r, 'dateFrom <= %d', $this->rangeEnd);
}
// TODO: Currently, the creator is always the only invitee, but you can
// query them separately since this won't always be true.
if ($this->invitedPHIDs) {
$where[] = qsprintf($conn_r, 'userPHID IN (%Ls)', $this->invitedPHIDs);
}
if ($this->creatorPHIDs) {
$where[] = qsprintf($conn_r, 'userPHID IN (%Ls)', $this->creatorPHIDs);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
}
示例9: buildWhereClause
protected function buildWhereClause(AphrontDatabaseConnection $conn_r)
{
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf($conn_r, 'id IN (%Ld)', $this->ids);
}
if ($this->objectPHIDs !== null) {
$where[] = qsprintf($conn_r, 'objectPHID IN (%Ls)', $this->objectPHIDs);
}
if ($this->tokens !== null) {
$where[] = qsprintf($conn_r, 'token IN (%Ls)', $this->tokens);
}
if ($this->tokenTypes !== null) {
$where[] = qsprintf($conn_r, 'tokenType IN (%Ls)', $this->tokenTypes);
}
if ($this->expired !== null) {
if ($this->expired) {
$where[] = qsprintf($conn_r, 'expires <= %d', PhabricatorTime::getNow());
} else {
$where[] = qsprintf($conn_r, 'expires IS NULL OR expires > %d', PhabricatorTime::getNow());
}
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
}
示例10: buildWhereClause
protected function buildWhereClause(AphrontDatabaseConnection $conn_r)
{
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf($conn_r, 'id IN (%Ld)', $this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf($conn_r, 'phid IN (%Ls)', $this->phids);
}
if ($this->networkPHIDs !== null) {
$where[] = qsprintf($conn_r, 'networkPHID IN (%Ls)', $this->networkPHIDs);
}
if ($this->devicePHIDs !== null) {
$where[] = qsprintf($conn_r, 'devicePHID IN (%Ls)', $this->devicePHIDs);
}
if ($this->addresses !== null) {
$parts = array();
foreach ($this->addresses as $address) {
$parts[] = qsprintf($conn_r, '(networkPHID = %s AND address = %s AND port = %d)', $address->getNetworkPHID(), $address->getAddress(), $address->getPort());
}
$where[] = implode(' OR ', $parts);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
}
示例11: buildWhereClause
protected function buildWhereClause(AphrontDatabaseConnection $conn_r)
{
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf($conn_r, 'id IN (%Ld)', $this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf($conn_r, 'phid IN (%Ls)', $this->phids);
}
if ($this->names !== null) {
$hashes = array();
foreach ($this->names as $name) {
$hashes[] = PhabricatorHash::digestForIndex($name);
}
$where[] = qsprintf($conn_r, 'nameIndex IN (%Ls)', $hashes);
}
if ($this->namePrefix !== null) {
$where[] = qsprintf($conn_r, 'name LIKE %>', $this->namePrefix);
}
if ($this->nameSuffix !== null) {
$where[] = qsprintf($conn_r, 'name LIKE %<', $this->nameSuffix);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
}
示例12: execute
protected function execute(ConduitAPIRequest $request)
{
$viewer = $request->getUser();
$repository_phid = $request->getValue('repositoryPHID');
$repository = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withPHIDs(array($repository_phid))->executeOne();
if (!$repository) {
throw new Exception(pht('No repository exists with PHID "%s".', $repository_phid));
}
$commit_name = $request->getValue('commit');
$commit = id(new DiffusionCommitQuery())->setViewer($viewer)->withRepository($repository)->withIdentifiers(array($commit_name))->executeOne();
if (!$commit) {
throw new Exception(pht('No commit exists with identifier "%s".', $commit_name));
}
$branch = PhabricatorRepositoryBranch::loadOrCreateBranch($repository->getID(), $request->getValue('branch'));
$coverage = $request->getValue('coverage');
$path_map = id(new DiffusionPathIDQuery(array_keys($coverage)))->loadPathIDs();
$conn = $repository->establishConnection('w');
$sql = array();
foreach ($coverage as $path => $coverage_info) {
$sql[] = qsprintf($conn, '(%d, %d, %d, %s)', $branch->getID(), $path_map[$path], $commit->getID(), $coverage_info);
}
$table_name = 'repository_coverage';
$conn->openTransaction();
queryfx($conn, 'DELETE FROM %T WHERE branchID = %d', $table_name, $branch->getID());
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
queryfx($conn, 'INSERT INTO %T (branchID, pathID, commitID, coverage) VALUES %Q', $table_name, $chunk);
}
$conn->saveTransaction();
}
示例13: buildWhereClause
protected function buildWhereClause(AphrontDatabaseConnection $conn_r)
{
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf($conn_r, 'id IN (%Ld)', $this->ids);
}
if ($this->objectPHIDs !== null) {
$where[] = qsprintf($conn_r, 'objectPHID IN (%Ls)', $this->objectPHIDs);
}
if ($this->tokenTypes !== null) {
$where[] = qsprintf($conn_r, 'tokenType IN (%Ls)', $this->tokenTypes);
}
if ($this->expired !== null) {
if ($this->expired) {
$where[] = qsprintf($conn_r, 'tokenExpires <= %d', time());
} else {
$where[] = qsprintf($conn_r, 'tokenExpires > %d', time());
}
}
if ($this->tokenCodes !== null) {
$where[] = qsprintf($conn_r, 'tokenCode IN (%Ls)', $this->tokenCodes);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
}
示例14: setKeys
public function setKeys(array $keys, $ttl = null)
{
if (PhabricatorEnv::isReadOnly()) {
return;
}
if ($keys) {
$map = $this->digestKeys(array_keys($keys));
$conn_w = $this->establishConnection('w');
$sql = array();
foreach ($map as $key => $hash) {
$value = $keys[$key];
list($format, $storage_value) = $this->willWriteValue($key, $value);
$sql[] = qsprintf($conn_w, '(%s, %s, %s, %B, %d, %nd)', $hash, $key, $format, $storage_value, time(), $ttl ? time() + $ttl : null);
}
$guard = AphrontWriteGuard::beginScopedUnguardedWrites();
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
queryfx($conn_w, 'INSERT INTO %T
(cacheKeyHash, cacheKey, cacheFormat, cacheData,
cacheCreated, cacheExpires) VALUES %Q
ON DUPLICATE KEY UPDATE
cacheKey = VALUES(cacheKey),
cacheFormat = VALUES(cacheFormat),
cacheData = VALUES(cacheData),
cacheCreated = VALUES(cacheCreated),
cacheExpires = VALUES(cacheExpires)', $this->getTableName(), $chunk);
}
unset($guard);
}
return $this;
}
示例15: buildWhereClause
protected function buildWhereClause(AphrontDatabaseConnection $conn_r)
{
$where = array();
if ($this->ids) {
$where[] = qsprintf($conn_r, 'id IN (%Ld)', $this->ids);
}
if ($this->phids) {
$where[] = qsprintf($conn_r, 'phid IN (%Ls)', $this->phids);
}
if ($this->providerClasses) {
$where[] = qsprintf($conn_r, 'providerClass IN (%Ls)', $this->providerClasses);
}
$status = $this->status;
switch ($status) {
case self::STATUS_ALL:
break;
case self::STATUS_ENABLED:
$where[] = qsprintf($conn_r, 'isEnabled = 1');
break;
default:
throw new Exception("Unknown status '{$status}'!");
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
}