Created
December 29, 2010 02:46
-
-
Save clasen/758093 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct script access.'); | |
class Database_Query_Builder_Update extends Kohana_Database_Query_Builder_Update { | |
/** | |
* Compile the SQL query and return it. | |
* | |
* @param object Database instance | |
* @return string | |
*/ | |
public function compile(Database $db) | |
{ | |
// Start an update query | |
$query = 'UPDATE '.$db->quote_table($this->_table); | |
// Add the columns to update | |
$query .= ' SET '.$this->_compile_set($db, $this->_set); | |
if ( ! empty($this->_where)) | |
{ | |
// Add selection conditions | |
$query .= ' WHERE '.$this->_compile_conditions($db, $this->_where); | |
} | |
if ( ! empty($this->_order_by)) | |
{ | |
// Add sorting | |
$query .= ' '.$this->_compile_order_by($db, $this->_order_by); | |
} | |
if ($this->_limit !== NULL) | |
{ | |
// Add limiting | |
$query .= ' LIMIT '.$this->_limit; | |
} | |
return $query; | |
} | |
public function reset() | |
{ | |
$this->_order_by = array(); | |
$this->_limit = NULL; | |
return parent::reset(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment