Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 类stdClass的对象无法转换为字符串错误_Php_Codeigniter - Fatal编程技术网

Php 类stdClass的对象无法转换为字符串错误

Php 类stdClass的对象无法转换为字符串错误,php,codeigniter,Php,Codeigniter,我试图将一个值从数据库传递到输入,但抛出以下错误。我不确定在这种情况下是否应该使用return$this->db->get()->row();在模型中。欢迎任何帮助 A PHP Error was encountered Severity: 4096 Message: Object of class stdClass could not be converted to string Filename: usuarios/vConsulta_Horarios.php Line Number

我试图将一个值从数据库传递到输入,但抛出以下错误。我不确定在这种情况下是否应该使用return$this->db->get()->row();在模型中。欢迎任何帮助

A PHP Error was encountered

Severity: 4096

Message: Object of class stdClass could not be converted to string

Filename: usuarios/vConsulta_Horarios.php

Line Number: 590

Backtrace:

File: C:\xampp\htdocs\SAE\application\views\usuarios\vConsulta_Horarios.php
Line: 590
Function: _error_handler

File: C:\xampp\htdocs\SAE\application\controllers\cCalendar.php
Line: 26
Function: view

File: C:\xampp\htdocs\SAE\index.php
Line: 315
Function: require_once
模型(McAllendar)

控制器(cCalendar)

看法


费查

即使您只选择了一列,但在输出时仍然需要指定它,因为
$start\u lunes
是表示整行的对象,并且错误告诉您,它无法转换为字符串

我认为
echo$start\u lunes->hrs\u ini
应该可以工作


基于您更新的函数,我认为如果您在select中为MIN表达式添加别名会更容易

$this->db->select('MIN(horario.hrs_ini) AS min_hrs');

然后在视图中引用它:
echo$start\u lunes->min\u hrs

作为
return$this->db->get()->row()返回您收到此错误的对象
你需要参考

所以现在,我建议你一件事,正确地返回数据。 在控制器中,更改返回
$this->db->get()->row()

现在,您正在以数组格式获取数据,您可以使用

//在您看来

foreach($start_lunes as $var){
        $value = $var['MIN(horario.hrs_ini)'];
    }

<input type="text" id="fecha_actual" name="fecha_actual" value="<?php echo $value?>"
foreach($start\u lunes作为$var){
$value=$var['MIN(horario.hrs_ini)';
}

你能添加cCalendar.php的代码吗?是controllerah,对不起,我误读了!您使用什么来管理数据库?“row()”的结果可能不是一个单一的值,但是objectI应该返回这个17:30:00,它只会始终返回一个结果do var_dump($start_lunes);让我们知道出口是什么?它有什么作用?同样的错误?不同的错误?什么都没有?$data['start_lunes']=$this->mCalendar->lunes();var_dump($start_lunes);应该往这边走吗?我从未使用过它,只需在视图页面的顶部添加var_dump()。。。这将显示变量try to print_r($start_lunes)的内容;告诉我该数组的结果([0]=>数组([MIN(horario.hrs\u ini)]=>15:30:00))
    <div class="col-md-2">

        <div class="form-group">
          <label>fecha</label>
          <input tupr="text" id="fecha_actual" name="fecha_actual" value="<?php echo $start_lunes;?>">
        </div>
     </div>
$this->db->select('MIN(horario.hrs_ini) AS min_hrs');
  return $this->db->get()->result_array();
foreach($start_lunes as $var){
        $value = $var['MIN(horario.hrs_ini)'];
    }

<input type="text" id="fecha_actual" name="fecha_actual" value="<?php echo $value?>"