eZ\Publish\Core\Persistence\Database\Query::bindValue PHP Method

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.
    public function bindValue($value, $placeHolder = null, $type = PDO::PARAM_STR);

Usage Example

 /**
  * 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));
 }
All Usage Examples Of eZ\Publish\Core\Persistence\Database\Query::bindValue