setValue() public method

$qb = $conn->createQueryBuilder() ->insert('users') ->values( array( 'name' => '?' ) ) ->setValue('password', '?');
public setValue ( string $column, string $value )
$column string The column into which the value should be inserted.
$value string The value that should be inserted into the column.
Esempio n. 1
0
 private function setAddValues(array $serialized, QueryBuilder $qb)
 {
     $i = 0;
     foreach ($serialized as $column => $value) {
         $qb->setValue($column, '?');
         $qb->setParameter($i, $value);
         ++$i;
     }
 }
Esempio n. 2
0
 /**
  * Sets the values and parameters of the upcoming given query according
  * to the entity.
  *
  * @param CRUDEntity $entity
  * the entity with its fields and values
  * @param QueryBuilder $queryBuilder
  * the upcoming query
  * @param boolean $setValue
  * whether to use QueryBuilder::setValue (true) or QueryBuilder::set (false)
  */
 protected function setValuesAndParameters(CRUDEntity $entity, QueryBuilder $queryBuilder, $setValue)
 {
     $formFields = $this->definition->getEditableFieldNames();
     $count = count($formFields);
     for ($i = 0; $i < $count; ++$i) {
         $value = $entity->get($formFields[$i]);
         $type = $this->definition->getType($formFields[$i]);
         if ($type == 'bool') {
             $value = $value ? 1 : 0;
         }
         if ($type == 'date' || $type == 'datetime' || $type == 'reference') {
             $value = $value == '' ? null : $value;
         }
         if ($setValue) {
             $queryBuilder->setValue('`' . $formFields[$i] . '`', '?');
         } else {
             $queryBuilder->set('`' . $formFields[$i] . '`', '?');
         }
         $queryBuilder->setParameter($i, $value);
     }
 }
 /**
  * @test
  */
 public function setValueWithoudNamedParameterQuotesIdentifierAndDelegatesToConcreteQueryBuilder()
 {
     $this->connection->quoteIdentifier('aField')->shouldBeCalled()->willReturnArgument(0);
     $this->concreteQueryBuilder->setValue('aField', 'aValue')->shouldBeCalled()->willReturn($this->subject);
     $this->subject->setValue('aField', 'aValue', false);
 }
Esempio n. 4
0
 /**
  * Sets a value for a column in an insert query.
  *
  * <code>
  *     $qb = $conn->getQueryBuilder()
  *         ->insert('users')
  *         ->values(
  *             array(
  *                 'name' => '?'
  *             )
  *         )
  *         ->setValue('password', '?');
  * </code>
  *
  * @param string $column The column into which the value should be inserted.
  * @param string $value The value that should be inserted into the column.
  *
  * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
  */
 public function setValue($column, $value)
 {
     $this->queryBuilder->setValue($this->helper->quoteColumnName($column), $value);
     return $this;
 }
Esempio n. 5
0
 /**
  * Sets a value for a column in an insert query.
  *
  * @param string $column The column into which the value should be inserted.
  * @param string $value The value that should be inserted into the column.
  * @param bool $createNamedParameter Automatically create a named parameter for the value
  *
  * @return QueryBuilder This QueryBuilder instance.
  */
 public function setValue(string $column, $value, bool $createNamedParameter = true) : QueryBuilder
 {
     $this->concreteQueryBuilder->setValue($this->quoteIdentifier($column), $createNamedParameter ? $this->createNamedParameter($value) : $value);
     return $this;
 }