Permalink
Browse files

Added support for using the "AS" keyword in the "columns" argument fo…

…r the "select" method. Fixes #34
  • Loading branch information...
stefangabos committed Jul 20, 2017
1 parent 3ed0486 commit fa48abf2b0bdd031790234d275f7d2871de7a778
Showing with 8 additions and 3 deletions.
  1. +8 −3 Zebra_Database.php
View
@@ -7,7 +7,7 @@
* Read more {@link https://github.com/stefangabos/Zebra_Database here}
*
* @author Stefan Gabos <contact@stefangabos.ro>
* @version 2.9.10 (last revision: June 15, 2017)
* @version 2.9.10 (last revision: July 20, 2017)
* @copyright (c) 2006 - 2017 Stefan Gabos
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU LESSER GENERAL PUBLIC LICENSE
* @package Zebra_Database
@@ -4489,10 +4489,15 @@ private function _escape($entries) {
$value = trim(trim($value, '`'));
// if not * or a MySQL function
if ($value !== '*' && !$this->_is_mysql_function($value))
if ($value !== '*' && !$this->_is_mysql_function($value)) {
// if alias is used
if (stripos($value, ' as ') !== false) list($value, $alias) = array_map(function($value) { return trim($value); }, preg_split('/ as /i', $value));
// enclose value in grave accents
return '`' . $value . '`';
return '`' . $value . '`' . (isset($alias) ? ' AS ' . $alias : '');
}
// return the value as it is otherwise
return $value;

0 comments on commit fa48abf

Please sign in to comment.