Update readme and added 'get_compiled_' methods to query builder

This commit is contained in:
Timothy Warren 2012-09-13 15:44:57 +00:00
parent 92c989e6f8
commit 559f3ab13a
3 changed files with 108 additions and 2 deletions

View File

@ -45,7 +45,7 @@ Create a connection array or object similar to this:
The parameters required depend on the database.
### Running Queries
Query uses the same interface as CodeIgniter's [Active Record class](http://codeigniter.com/user_guide/database/active_record.html). However, it does not implement the `insert_batch` or `update_batch` methods.
Query uses the same interface as CodeIgniter's [Active Record class](http://codeigniter.com/user_guide/database/active_record.html). However, it does not implement the `insert_batch`, `update_batch` or caching methods.
####You can also run queries manually.

View File

@ -1247,11 +1247,116 @@ class Query_Builder {
return $res;
}
// --------------------------------------------------------------------------
// ! Query Returning Methods
// --------------------------------------------------------------------------
/**
* Returns the generated 'select' sql query
*
* @param string $table
* @param bool $reset
* @return string
*/
public function get_compiled_select($table='', $reset=TRUE)
{
// Set the table
if ( ! empty($table))
{
$this->from($table);
}
$sql = $this->_compile();
// Reset the query builder for the next query
if ($reset)
{
$this->_reset();
}
return $sql;
}
// --------------------------------------------------------------------------
/**
* Returns the generated 'insert' sql query
*
* @param string $table
* @param bool $reset
* @return string
*/
public function get_compiled_insert($table, $reset=TRUE)
{
$sql = $this->_compile("insert", $table);
// Reset the query builder for the next query
if ($reset)
{
$this->_reset();
}
return $sql;
}
// --------------------------------------------------------------------------
/**
* Returns the generated 'insert' sql query
*
* @param string $table
* @param bool $reset
* @return string
*/
public function get_compiled_update($table='', $reset=TRUE)
{
$sql = $this->_compile('update', $table);
// Reset the query builder for the next query
if ($reset)
{
$this->_reset();
}
return $sql;
}
// --------------------------------------------------------------------------
/**
* Returns the generated 'insert' sql query
*
* @param string $table
* @param bool $reset
* @return string
*/
public function get_compiled_delete($table="", $reset=TRUE)
{
$sql = $this->_compile("delete", $table);
// Reset the query builder for the next query
if ($reset)
{
$this->_reset();
}
return $sql;
}
// --------------------------------------------------------------------------
// ! Miscellaneous Methods
// --------------------------------------------------------------------------
/**
* Resets the query builder for the next query
*/
public function reset_query()
{
$this->_reset();
}
// --------------------------------------------------------------------------
/**
* Calls a function further down the inheritence chain
*
@ -1286,7 +1391,8 @@ class Query_Builder {
// Skip properties that are needed for every query
if (in_array($name, array(
'db',
'sql'
'sql',
'queries',
)))
{
continue;

Binary file not shown.