dtvnnhh8992 2015-06-19 19:38
浏览 71

$ stmt-> store_result()不返回mysqli_result

perhaps this is a duplicate question, but I have read very many threads that deal with this issue and I can not find the solution, if indeed this is a duplicate question and I apologize if you do not mind give me a link that can help me. the problem is this: for reasons of my hosting plan I can not use 'mysqli_stmt_get_result ()' so I try to change the script I wrote (I'm just learning php), but then you run the query have no way to obtain the results of the consultation which if obtenia using 'mysqli_stmt_get_result ()', as an alternative to this I am trying to get that result with 'mysqli_store_result' which according to the documentation alcanso to read (as I understand) "Returns a buffered result object or FALSE if an error occurred." should (if all goes well) give me the same result I have with 'mysqli_stmt_get_result ()' and should only return "FALSE" in case something went wrong, but what I do I always get a Boolean = true. Could someone help me I'm doing wrong ?, some easy replacement of 'mysqli_stmt_get_result ()'? this is a fragment of what I have to code:

$link = new mysqli(
    "localhost",
    "root",
    "RootPass",
    "DB"
);
echo "


";
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
if($_GET){
  $where_value = trim(htmlspecialchars($_GET["where"]));
}else{
  if(count($argv)>1){
    $where_value = trim($argv[1]);
  }else{
    $where_value = '';
  }
}
if($where_value != ''){
  if($stmt = $link->prepare('SELECT * FROM Tabla_1 WHERE ID=?')){
    $stmt->bind_param('i', $where_value);
   }else{
    echo mysqli_stmt_errno;
    exit();
  }
}else{
  if(!$stmt = $link->prepare('SELECT * FROM Table_1')){
    echo mysqli_stmt_errno;
    exit();
  }
}
$stmt->execute();
$result = $stmt->store_result(); // Store "true" but must be 'mysqli_result'

// From this point none work because $result is a boolean not a 'mysqli_result'
$resultArray = array();
$tempArray = array();
while($row = $result->fetch_array(MYSQLI_NUM)){
  $tempArray = $row;
  array_push($resultArray, $tempArray);
}
mysqli_close($con);
echo json_encode($resultArray);

'Mysqli_stmt_bind_result' is not an option for me because the table has lots of columns, unless you can use an array for the 'mysqli_stmt_bind_result'.

my sistem is:

php --version
PHP 5.6.9-0+deb8u1 (cli) (built: Jun  5 2015 11:03:27) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies
lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 8.1 (jessie)
Release:        8.1
Codename:       jessie
uname -a
Linux Iwakura-PC 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64 GNU/Linux

Please any help will be greatly appreciated

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
    • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
    • ¥60 pb数据库修改与连接
    • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
    • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
    • ¥20 神经网络Sequential name=sequential, built=False
    • ¥16 Qphython 用xlrd读取excel报错
    • ¥15 单片机学习顺序问题!!
    • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
    • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)