Browse Source

Merge pull request #732 from franzliedke/patch-4

Add a last_query() function to Database connection class.
Taylor Otwell 12 years ago
parent
commit
f608157ffc
2 changed files with 24 additions and 0 deletions
  1. 12 0
      laravel/database.php
  2. 12 0
      laravel/database/connection.php

+ 12 - 0
laravel/database.php

@@ -133,6 +133,18 @@ class Database {
 	{
 	{
 		return Database\Connection::$queries;
 		return Database\Connection::$queries;
 	}
 	}
+	
+	/**
+	 * Get the last query that was executed.
+	 *
+	 * Returns false if no queries have been executed yet.
+	 *
+	 * @return string
+	 */
+	public static function last_query()
+	{
+		return Database\Connection::last_query();
+	}
 
 
 	/**
 	/**
 	 * Register a database connector and grammars.
 	 * Register a database connector and grammars.

+ 12 - 0
laravel/database/connection.php

@@ -332,5 +332,17 @@ class Connection {
 	{
 	{
 		return $this->table($method);
 		return $this->table($method);
 	}
 	}
+	
+	/**
+	 * Get the last query that was executed.
+	 * 
+	 * Returns false if no queries have been executed yet.
+	 *
+	 * @return string
+	 */
+	public static function last_query()
+	{
+		return end(static::$queries);
+	}
 
 
 }
 }