本文整理汇总了PHP中mysqli_stmt::fetch_fields方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_stmt::fetch_fields方法的具体用法?PHP mysqli_stmt::fetch_fields怎么用?PHP mysqli_stmt::fetch_fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqli_stmt
的用法示例。
在下文中一共展示了mysqli_stmt::fetch_fields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
//.........这里部分代码省略.........
* @return bool Returns TRUE on success or FALSE on failure.
* @throws \InvalidArgumentException
* @api
*/
public function execute(array $input_parameters = array())
{
$parameterValues = $this->parameters;
if (!empty($input_parameters)) {
$parameterValues = array();
foreach ($input_parameters as $key => $value) {
$parameterValues[$key] = array('value' => $value, 'type' => $this->guessValueType($value));
}
}
if ($this->statement !== NULL) {
// The statement has already been executed, we try to reset it
// for current run but will set it to NULL if it fails for some
// reason, just as if it were the first run
if (!@$this->statement->reset()) {
$this->statement = NULL;
}
}
if ($this->statement === NULL) {
// The statement has never been executed so we prepare it and
// store it for further reuse
$query = $this->query;
$precompiledQueryParts = $this->precompiledQueryParts;
$this->convertNamedPlaceholdersToQuestionMarks($query, $parameterValues, $precompiledQueryParts);
if (!empty($precompiledQueryParts)) {
$query = implode('', $precompiledQueryParts['queryParts']);
}
$this->statement = $GLOBALS['TYPO3_DB']->prepare_PREPAREDquery($query, $precompiledQueryParts);
if ($this->statement === NULL) {
return FALSE;
}
}
$combinedTypes = '';
$values = array();
foreach ($parameterValues as $parameterValue) {
switch ($parameterValue['type']) {
case self::PARAM_NULL:
$type = 's';
$value = NULL;
break;
case self::PARAM_INT:
$type = 'i';
$value = (int) $parameterValue['value'];
break;
case self::PARAM_STR:
$type = 's';
$value = $parameterValue['value'];
break;
case self::PARAM_BOOL:
$type = 'i';
$value = $parameterValue['value'] ? 1 : 0;
break;
default:
throw new \InvalidArgumentException(sprintf('Unknown type %s used for parameter %s.', $parameterValue['type'], $key), 1281859196);
}
$combinedTypes .= $type;
$values[] = $value;
}
// ->bind_param requires second up to last arguments as references
if (!empty($combinedTypes)) {
$bindParamArguments = array();
$bindParamArguments[] = $combinedTypes;
$numberOfExtraParamArguments = count($values);
for ($i = 0; $i < $numberOfExtraParamArguments; $i++) {
$bindParamArguments[] =& $values[$i];
}
call_user_func_array(array($this->statement, 'bind_param'), $bindParamArguments);
}
$success = $this->statement->execute();
// Store result
if (!$success || $this->statement->store_result() === FALSE) {
return FALSE;
}
if (empty($this->fields)) {
// Store the list of fields
if ($this->statement instanceof \mysqli_stmt) {
$result = $this->statement->result_metadata();
if ($result instanceof \mysqli_result) {
$fields = $result->fetch_fields();
$result->close();
}
} else {
$fields = $this->statement->fetch_fields();
}
if (is_array($fields)) {
foreach ($fields as $field) {
$this->fields[] = $field->name;
}
}
}
// New result set available
$this->buffer = NULL;
// Empty binding parameters
$this->parameters = array();
// Return the success flag
return $success;
}