pear problem
-
hey.
also ich hab folgende funktion:
function selectBlock( $sql, $args ) { global $db; $res = $db->query( $sql, $args ); $rows = array( ); while( $res->fetchInto($row, DB_FETCHMODE_ASSOC) ) { $rows []= $row; } return $rows; }
diese rufe ich hier auf:
class check_db_integritaet{ var $id; var $table; var $status; var $value; function check_db_integritaet($id, $table) { $this->id = $id; $this->table = $table; /* ich muss anstelle von bsp. careerinfo ein ? schreiben und hinten im array dann die eigentlichen variablen */ $this->status = selectBlock( "SELECT * FROM profil INNER JOIN (?) ON profil.id_? = ?.id WHERE profil.id = ?", array($table, $table, $table, $id) ); } function get_status( ) { if(count($this->status) >= 1) { return true; } else { return false; } } } [/code für jedes ? hab ich auch hinten im array die variable reingeschrieben, aber es kommt folgende fehlermeldung: [code]Fatal error: Call to undefined method DB_Error::fetchInto() in C:\xampp\htdocs\projects\model\dbwrap.php on line 29
Und Line 29 ist genau folgende Zeile:
while( $res->fetchInto($row, DB_FETCHMODE_ASSOC) ) { $rows []= $row; }
Wenn ich das ganze nur mit einem ? und nur mit "id" mache, ist es kein problem. Funktioniert einwandfrei. Aber sobald ich da mehrere dinge durch ? ersetzen will kommt diese fehlermeldung.
echo $res->getDebugInfo();
nur wie beheb ich den?
SELECT * FROM profil INNER JOIN ('lookingfor') ON profil.id_'lookingfor' = 'lookingfor'.id WHERE profil.id = '1' [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''lookingfor') ON profil.id_'lookingfor' = 'lookingfor'.id WHERE profil.id = '1'' at line 1]
sind das die ' ' zeichen die den sql-fehler produzieren? weil da steht ja zb 'lookingfor'.id aber da sollte ja eigentlich lookingfor.id stehen, er macht da automatisch die ' ' zeichen hin
könnte man das irgendwie anders schreiben?
liebe grüße und vielen dank!
-
Ich kenne mich mit dieser DB-Schicht nicht so aus, aber mir fallen zwei Dinge auf:
DB_Error::fetchInto() : Möglicherweise ist hier ein Fehler schon entstanden, so dass res nicht vom Typ Resultset, sondern vom Typ Fehler ist, welcher die Methode fetchInto nicht kennt. Das ist aber nur ein Folgefehler. Könnte sein, dass ? die Ersetzung eines Stringliterales ist. Funktioniert denn der klassische Weg? "SELECT * FROM profil INNER JOIN (table) ON profil.id_$table = $table.id WHERE profil.id = $id";