Ich verwende Eloquent 5. * auf meinem CodeIgniter3.1.1 Projekt, funktioniert alles aber fein i ausgeführt, um die Anfragen überprüfen möchten, wenn eine Anfrage bearbeitet wird,Wie beredt Abfragen in Codeigniter ausgeführt debuggen
Nach einigen googeln ich kam accross Using Eloquent ORM inside CodeIgniter with added Query Logging und mit CI Profiler aktiviert i "Keine queries executed" zu sehen,
meine database.php
Konfiguration für Eloquent sieht wie unten
//Eloquent ORM database connection
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;
$capsule->addConnection(array(
'driver' => 'mysql',
'dsn' => 'mysql:host=localhost; dbname=communit_iwa_test charset=utf8;',
'host' => $db['default']['hostname'],
'database' => $db['default']['database'],
'username' => $db['default']['username'],
'password' => $db['default']['password'],
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => $db['default']['dbprefix'],
));
$capsule->setAsGlobal();
$capsule->bootEloquent();
$events = new Illuminate\Events\Dispatcher;
$events->listen('illuminate.query',function($query, $bindings, $time,$name) {
// Format binding data for sql insertion
foreach ($bindings as $i => $binding) {
if ($binding instanceof \DateTime) {
$bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
} else if (is_string($binding)) {
$bindings[$i] = "'$binding'";
}
}
// Insert bindings into query
$query = str_replace(array('%', '?'), array('%%', '%s'), $query);
$query = vsprintf($query, $bindings);
// Add it into CodeIgniter
$db = & get_instance()->db;
$db->query_times[] = $time;
$db->queries[] = $query;
});
$capsule->setEventDispatcher($events);
/* End of file database.php */
/* Location: ./application/config/database.php */
Ihre Hilfe im Voraus geschätzt
Hallo, ich habe den gleichen Profi blem, Profiler ist leer für Abfragen, hast du es behoben? – Piero
Verwenden Sie 'Capsule :: getQueryLog()' Methode, um Abfragen in eloquenten ORM – hussainfrotan
ausgeführt zu sehen Ja danke! (Als Genauigkeit benötigt Capsule :: enableQueryLog()) – Piero