无法将类stdClass的PDO功能对象转换为字符串

时间:2019-08-15 16:58:20

标签: php

我希望你能帮助我。我真的很难解决此代码,它是为Mysql编码的,现在我想将其传递给PDO。

$sql = " SELECT
        text_content
        FROM
        {$text_table}
        WHERE
        text_name = '{$this->database->escape($p_text_name)}'";

$queries = array(
    array(
        'sql'=> "{$sql} AND text_language_id='{$this->language['language_id']}' AND     text_page_id='{$sql_page_id}'",
        'error'     => false,
        'description'   => "seitenspezifisch, aktuelle Sprache {$this->language['language_locale_iso_short']}",
        ),
    array(
        'sql'=> "{$sql} AND text_language_id='{$this->language['language_id']}' AND text_page_id=0",
        'error' => iSYSTEM_CONFIG_LOG_LEVEL_LOW,
        'description'   => "global, aktuelle Sprache {$this->language['language_locale_iso_short']}",
    )
);

foreach ($queries as $query) {
    $result = $this->database->query_and_fetch($query['sql']);
    if ( $result !== false ) {  
        $found = true;
        break;
    } else {
        if ($query['error'] !== false) {
            log::error($query['error'], "Text {$p_text_name} not found ({$query['description']})");
        }
    }               
}

我已经尝试过:

// Get single record as object
public function single(){
    $this->execute();
    return $this->stmt->fetch(PDO::FETCH_OBJ);
}   

$this->database->query("SELECT text_content FROM {$text_table} WHERE text_name=:text_name");
$this->database->bind(':text_name',$p_text_name);

$sql = $this->database->single();
$sql = array();

我收到此错误:

  

可恢复的致命错误:stdClass类的对象无法转换为字符串

0 个答案:

没有答案