bindValues() public method

This is similar to Command::bindValue except that it binds multiple values at a time. Note that the SQL data type of each value is determined by its PHP type.
public bindValues ( array $values )
$values array the values to be bound. This must be given in terms of an associative array with array keys being the parameter names, and array values the corresponding parameter values, e.g. `[':name' => 'John', ':age' => 25]`. By default, the PDO type of each value is determined by its PHP type. You may explicitly specify the PDO type by using an array: `[value, type]`, e.g. `[':name' => 'John', ':profile' => [$profile, \PDO::PARAM_LOB]]`.
Ejemplo n.º 1
0
 /**
  * Creates a command for execution.
  * @param string $sql the SQL statement to be executed
  * @param array $params the parameters to be bound to the SQL statement
  * @return Command the DB command
  */
 public function createCommand($sql = null, $params = [])
 {
     $command = new Command(['db' => $this, 'sql' => $sql]);
     return $command->bindValues($params);
 }
Ejemplo n.º 2
0
 /**
  * Доработанная версия bindValues, умеет принимать массив в формате, который используется парсером (@see \app\components\Command::replaceComment())
  * @param array $values
  * @return static
  */
 public function bindValues($values)
 {
     return parent::bindValues((new Parser('', $values))->getSimplifiedParams());
 }
Ejemplo n.º 3
0
 /**
  * Write log message
  *
  * @param mixed       $message message to log
  * @param string|null $target target name (file, category, etc)
  * @param string      $level log level
  * @param string      $from string from __METHOD__ constant
  * @param array|null  $data addition data to handler
  * @return bool
  */
 public function write($message, $target = null, $level = ELogger::TRACE, $from = null, $data = null)
 {
     $this->command->bindValues(array(':message' => $message, ':level' => $level, ':target' => $target, ':source' => $from))->execute();
 }
Ejemplo n.º 4
0
 /**
  * @inheritdoc
  */
 public function bindValues($values)
 {
     if ($this->db->enableFloatConversion) {
         if (empty($values)) {
             return $this;
         }
         foreach ($values as $name => $value) {
             if (is_float($value)) {
                 $this->floatParams[$name] = $value;
                 unset($values[$name]);
             }
         }
     }
     return parent::bindValues($values);
 }