protected function bindParams($s, $aValues) { foreach ($aValues as $key => &$value) { if (is_integer($key)) { if (is_null($value)) { $s->bindValue($key + 1, null, PDO::PARAM_NULL); } elseif (!$this->flagUseStringOnlyBinding && RedBean_QueryWriter_AQueryWriter::canBeTreatedAsInt($value) && $value < 2147483648) { $s->bindParam($key + 1, $value, PDO::PARAM_INT); } else { $s->bindParam($key + 1, $value, PDO::PARAM_STR); } } else { if (is_null($value)) { $s->bindValue($key, null, PDO::PARAM_NULL); } elseif (!$this->flagUseStringOnlyBinding && RedBean_QueryWriter_AQueryWriter::canBeTreatedAsInt($value) && $value < 2147483648) { $s->bindParam($key, $value, PDO::PARAM_INT); } else { $s->bindParam($key, $value, PDO::PARAM_STR); } } } }
/** * Binds parameters. This method binds parameters to a PDOStatement for * Query Execution. This method binds parameters as NULL, INTEGER or STRING * and supports both named keys and question mark keys. * * @param PDOStatement $statement PDO Statement instance * @param array $bindings values that need to get bound to the statement * * @return void */ protected function bindParams($statement, $bindings) { foreach ($bindings as $key => &$value) { if (is_integer($key)) { if (is_null($value)) { $statement->bindValue($key + 1, NULL, PDO::PARAM_NULL); } elseif (!$this->flagUseStringOnlyBinding && RedBean_QueryWriter_AQueryWriter::canBeTreatedAsInt($value) && $value <= $this->max) { $statement->bindParam($key + 1, $value, PDO::PARAM_INT); } else { $statement->bindParam($key + 1, $value, PDO::PARAM_STR); } } else { if (is_null($value)) { $statement->bindValue($key, NULL, PDO::PARAM_NULL); } elseif (!$this->flagUseStringOnlyBinding && RedBean_QueryWriter_AQueryWriter::canBeTreatedAsInt($value) && $value <= $this->max) { $statement->bindParam($key, $value, PDO::PARAM_INT); } else { $statement->bindParam($key, $value, PDO::PARAM_STR); } } } }