Closed Rolaka closed 10 years ago
It`s not recommend to use SQL inbound function for SQL query that PHP native function can do it as well.
ic, thx catfan fix the "now()" \QAQ//
if change this, table alias "alias(tname)" for "alias[date_format(table,'xxx')]" works
protected function column_push( $columns )
{
if ( $columns == '*' ) {
return $columns ;
}
if ( is_string( $columns ) ) {
$columns = array( $columns ) ;
}
$stack = array() ;
foreach ( $columns as $key => $value ) {
preg_match( '/([a-zA-Z0-9_\-\.]*)\s*\[((.*?)*)\]/i', $value, $match ) ;
if ( isset( $match[1], $match[2] ) ) {
array_push( $stack, $match[2] . ' AS ' . $match[1] ) ;
} else {
array_push( $stack, $this->column_quote( $value ) ) ;
}
}
return implode( $stack, ',' ) ;
}
use this
$news = $database->get('article', array(
'id',
'title',
'asName'=>Medoo\Medoo::raw('DATE_FORMAT(date, "%m-%d-%Y")')
), array(
'type' => 'news',
'LIMIT' => '7'
));
->
QAQ...
PS: Had no choice, My dirty patch:
Use this format...