PHP - Necesito ayuda

 
Vista:

Necesito ayuda

Publicado por hans (2 intervenciones) el 15/08/2019 19:50:50
Benas tardes,
Estoy intentando pasar un codigo hecho en PHP5 a 7 y tengo algunos problemas.
Aqui el original:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?
public function get_text($p_text_name) {
    $text_table = $this->database->table_name_system('text');
    $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']}",
                    ));
 
    $found = false;
    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']})");
            }
        }
    }


Aqui el nuevo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Get result set as array of objects
public function resultset(){
    $this->execute();
    return $this->stmt->fetchAll(PDO::FETCH_ASSOC);
}
 
public function get_text($p_text_name) {
 
    $text_table = $this->database->table_name_system('text');
 
 
    $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->resultset();

Aqui el mensaje de error: Recoverable fatal error: Object of class stdClass could not be converted to string
1
2
Notice: Array to string conversion in
'sql'=> "{$sql} AND text_language_id='{$this->language['language_id']}' AND text_page_id='{$sql_page_id}'",

Espero que me podeis ayudar a encontrar la solución. Gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de joel
Val: 3.828
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Necesito ayuda

Publicado por joel (1269 intervenciones) el 16/08/2019 07:37:56
Hola Hans, en que linea te da ese error??

Puede ser que te falte publicar algo de código?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Necesito ayuda

Publicado por hans (2 intervenciones) el 16/08/2019 08:37:19
1
$queries = array(array( 'sql'=> "{$sql} AND text_language_id='{$this->language['language_id']}' AND text_page_id='{$sql_page_id}'",));

El problema proviene de la linea 15. sobretodo cuando manejo cada iteración( Quiero implementar el PDO y no lo se como hacer) Gracias Joel.

1
2
3
4
5
6
7
8
9
10
11
12
13
foreach ($queries as $query) {
    $result = $this->database->query_and_fetch($query['sql']);
 
    if ( $result !== false ) {
        // Text gefunden
        $found = true;
        break;
    } else {
        if ($query['error'] !== false) {
            log::error($query['error'], "Text {$p_text_name} nicht gefunden ({$query['description']})");
        }
    }
}



Captura-de-pantalla-123
Captura-de-pantalla-124
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar