Created
April 16, 2014 08:30
-
-
Save anonymous/10832577 to your computer and use it in GitHub Desktop.
overwrote Lemonstand Db_ActiveRecord select method
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
public function select($fields = '*', $table_fields = '', $replace_columns = false) | |
{ | |
if (strlen($table_fields) != 0) | |
{ | |
// 1. select(table, fields), append table. to fields | |
$table = $fields; | |
$fields = explode(',', $table_fields); | |
foreach($fields as &$field) { | |
if (strstr($field, '.') === false) { | |
$field = $table . '.' . $field; | |
} | |
} | |
} else { | |
// 2. select(fields) | |
$fields = explode(',', $fields); | |
} | |
// Merge fields | |
if ($replace_columns == false){ | |
$this->parts['fields'] = array_merge($this->parts['fields'], $fields); | |
} else { | |
$this->parts['fields'] = $fields; | |
} | |
return $this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment