本文整理汇总了PHP中OCP\IDBConnection::setValues方法的典型用法代码示例。如果您正苦于以下问题:PHP IDBConnection::setValues方法的具体用法?PHP IDBConnection::setValues怎么用?PHP IDBConnection::setValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\IDBConnection
的用法示例。
在下文中一共展示了IDBConnection::setValues方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetValuesSameNoError
public function testSetValuesSameNoError()
{
$this->makeTestTable();
$this->connection->setValues('table', ['integerfield' => 1], ['textfield' => 'foo', 'clobfield' => 'not_null']);
// this will result in 'no affected rows' on certain optimizing DBs
// ensure the PreConditionNotMetException isn't thrown
$this->connection->setValues('table', ['integerfield' => 1], ['textfield' => 'foo']);
}
示例2: setUserValue
/**
* Set a user defined value
*
* @param string $userId the userId of the user that we want to store the value under
* @param string $appName the appName that we want to store the value under
* @param string $key the key under which the value is being stored
* @param string $value the value that you want to store
* @param string $preCondition only update if the config value was previously the value passed as $preCondition
* @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
*/
public function setUserValue($userId, $appName, $key, $value, $preCondition = null)
{
// TODO - FIXME
$this->fixDIInit();
$preconditionArray = [];
if (isset($preCondition)) {
$preconditionArray = ['configvalue' => $preCondition];
}
$this->connection->setValues('preferences', ['userid' => $userId, 'appid' => $appName, 'configkey' => $key], ['configvalue' => $value], $preconditionArray);
// only add to the cache if we already loaded data for the user
if (isset($this->userCache[$userId])) {
if (!isset($this->userCache[$userId][$appName])) {
$this->userCache[$userId][$appName] = array();
}
$this->userCache[$userId][$appName][$key] = $value;
}
}
示例3: setUserValue
/**
* Set a user defined value
*
* @param string $userId the userId of the user that we want to store the value under
* @param string $appName the appName that we want to store the value under
* @param string $key the key under which the value is being stored
* @param string|float|int $value the value that you want to store
* @param string $preCondition only update if the config value was previously the value passed as $preCondition
* @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
* @throws \UnexpectedValueException when trying to store an unexpected value
*/
public function setUserValue($userId, $appName, $key, $value, $preCondition = null)
{
if (!is_int($value) && !is_float($value) && !is_string($value)) {
throw new \UnexpectedValueException('Only integers, floats and strings are allowed as value');
}
// TODO - FIXME
$this->fixDIInit();
$preconditionArray = [];
if (isset($preCondition)) {
$preconditionArray = ['configvalue' => $preCondition];
}
$this->connection->setValues('preferences', ['userid' => $userId, 'appid' => $appName, 'configkey' => $key], ['configvalue' => $value], $preconditionArray);
// only add to the cache if we already loaded data for the user
if (isset($this->userCache[$userId])) {
if (!isset($this->userCache[$userId][$appName])) {
$this->userCache[$userId][$appName] = array();
}
$this->userCache[$userId][$appName][$key] = $value;
}
}
示例4: setValues
/**
* Insert or update a row value
*
* @param string $table
* @param array $keys (column name => value)
* @param array $values (column name => value)
* @param array $updatePreconditionValues ensure values match preconditions (column name => value)
* @return int number of new rows
* @throws \Doctrine\DBAL\DBALException
* @throws PreconditionNotMetException
*/
public function setValues($table, array $keys, array $values, array $updatePreconditionValues = [])
{
return $this->connection->setValues($table, $keys, $values, $updatePreconditionValues);
}
示例5: store
/**
* Store a set of credentials
*
* @param string|null $userId Null for system-wide credentials
* @param string $identifier
* @param mixed $credentials
*/
public function store($userId, $identifier, $credentials)
{
$value = $this->crypto->encrypt(json_encode($credentials));
$this->dbConnection->setValues(self::DB_TABLE, ['user' => $userId, 'identifier' => $identifier], ['credentials' => $value]);
}
示例6: testSetValuesOverWritePreconditionFailed
/**
* @expectedException \OCP\PreConditionNotMetException
*/
public function testSetValuesOverWritePreconditionFailed()
{
$this->makeTestTable();
$this->connection->setValues('table', ['integerfield' => 1], ['textfield' => 'foo', 'booleanfield' => true, 'clobfield' => 'not_null']);
$this->connection->setValues('table', ['integerfield' => 1], ['textfield' => 'bar'], ['booleanfield' => false]);
}