bindValue() public method

This method provides a shortcut for PDOStatement::bindValue when using prepared statements. The parameter $value specifies the value that you want to bind. If $placeholder is not provided bindValue() will automatically create a placeholder for you. An automatic placeholder will be of the name 'placeholder1', 'placeholder2' etc. For more information see {@link http://php.net/pdostatement-bindparam} Example: $value = 2; $q->eq( 'id', $q->bindValue( $value ) ); $stmt = $q->prepare(); // the value 2 is bound to the query. $value = 4; $stmt->execute(); // executed with 'id = 2'
public bindValue ( mixed $value, string $placeHolder = null, $type = PDO::PARAM_STR ) : string
$value mixed
$placeHolder string the name to bind with. The string must start with a colon ':'.
return string the placeholder name used.
 /**
  * Set common columns for insert/update of FieldDefinition.
  *
  * @param \eZ\Publish\Core\Persistence\Database\InsertQuery|\eZ\Publish\Core\Persistence\Database\UpdateQuery $q
  * @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDefinition
  * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageFieldDef
  *
  * @return void
  */
 protected function setCommonFieldColumns(Query $q, FieldDefinition $fieldDefinition, StorageFieldDefinition $storageFieldDef)
 {
     $q->set($this->dbHandler->quoteColumn('serialized_name_list'), $q->bindValue(serialize($fieldDefinition->name)))->set($this->dbHandler->quoteColumn('serialized_description_list'), $q->bindValue(serialize($fieldDefinition->description)))->set($this->dbHandler->quoteColumn('identifier'), $q->bindValue($fieldDefinition->identifier))->set($this->dbHandler->quoteColumn('category'), $q->bindValue($fieldDefinition->fieldGroup, null, \PDO::PARAM_STR))->set($this->dbHandler->quoteColumn('placement'), $q->bindValue($fieldDefinition->position, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('data_type_string'), $q->bindValue($fieldDefinition->fieldType))->set($this->dbHandler->quoteColumn('can_translate'), $q->bindValue($fieldDefinition->isTranslatable ? 1 : 0, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('is_required'), $q->bindValue($fieldDefinition->isRequired ? 1 : 0, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('is_information_collector'), $q->bindValue($fieldDefinition->isInfoCollector ? 1 : 0, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('data_float1'), $q->bindValue($storageFieldDef->dataFloat1))->set($this->dbHandler->quoteColumn('data_float2'), $q->bindValue($storageFieldDef->dataFloat2))->set($this->dbHandler->quoteColumn('data_float3'), $q->bindValue($storageFieldDef->dataFloat3))->set($this->dbHandler->quoteColumn('data_float4'), $q->bindValue($storageFieldDef->dataFloat4))->set($this->dbHandler->quoteColumn('data_int1'), $q->bindValue($storageFieldDef->dataInt1, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('data_int2'), $q->bindValue($storageFieldDef->dataInt2, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('data_int3'), $q->bindValue($storageFieldDef->dataInt3, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('data_int4'), $q->bindValue($storageFieldDef->dataInt4, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('data_text1'), $q->bindValue($storageFieldDef->dataText1))->set($this->dbHandler->quoteColumn('data_text2'), $q->bindValue($storageFieldDef->dataText2))->set($this->dbHandler->quoteColumn('data_text3'), $q->bindValue($storageFieldDef->dataText3))->set($this->dbHandler->quoteColumn('data_text4'), $q->bindValue($storageFieldDef->dataText4))->set($this->dbHandler->quoteColumn('data_text5'), $q->bindValue($storageFieldDef->dataText5))->set($this->dbHandler->quoteColumn('serialized_data_text'), $q->bindValue(serialize($storageFieldDef->serializedDataText)))->set($this->dbHandler->quoteColumn('is_searchable'), $q->bindValue($fieldDefinition->isSearchable ? 1 : 0, null, \PDO::PARAM_INT));
 }
 /**
  * Sets value for insert or update query.
  *
  * @param \eZ\Publish\Core\Persistence\Database\Query|\eZ\Publish\Core\Persistence\Database\InsertQuery|\eZ\Publish\Core\Persistence\Database\UpdateQuery $query
  * @param array $values
  *
  * @throws \Exception
  *
  * @return void
  */
 protected function setQueryValues(Query $query, $values)
 {
     foreach ($values as $column => $value) {
         // @todo remove after testing
         if (!in_array($column, $this->columns["ezurlalias_ml"])) {
             throw new \Exception("unknown column '{$column}' for table 'ezurlalias_ml'");
         }
         switch ($column) {
             case "text":
             case "action":
             case "text_md5":
             case "action_type":
                 $pdoDataType = \PDO::PARAM_STR;
                 break;
             default:
                 $pdoDataType = \PDO::PARAM_INT;
         }
         $query->set($this->dbHandler->quoteColumn($column), $query->bindValue($value, null, $pdoDataType));
     }
 }
 /**
  * Limits the given $query to the subtree starting at $rootLocationId.
  *
  * @param \eZ\Publish\Core\Persistence\Database\Query $query
  * @param string $rootLocationId
  */
 protected function applySubtreeLimitation(DatabaseQuery $query, $rootLocationId)
 {
     $query->where($query->expr->like($this->handler->quoteColumn('path_string', 'ezcontentobject_tree'), $query->bindValue('%/' . $rootLocationId . '/%')));
 }
 /**
  * Sets columns in $query from $language.
  *
  * @param \eZ\Publish\Core\Persistence\Database\Query $query
  * @param \eZ\Publish\SPI\Persistence\Content\Language $language
  */
 protected function setCommonLanguageColumns(Query $query, Language $language)
 {
     $query->set($this->dbHandler->quoteColumn('locale'), $query->bindValue($language->languageCode))->set($this->dbHandler->quoteColumn('name'), $query->bindValue($language->name))->set($this->dbHandler->quoteColumn('disabled'), $query->bindValue((int) (!$language->isEnabled), null, \PDO::PARAM_INT));
 }