Jonathon Posted June 17, 2013 Share Posted June 17, 2013 I was reading the docs for the select call http://www.yiiframework.com/doc/api/1.1/CDbCommand#select()-detail it says: Columns can be specified in either a string (e.g. "id, name") or an array (e.g. array('id', 'name')) I've actually done some hybrid version with $cmd->select(array('column1, column2, column3')); Will that be problematic at all? I can change it, it looked ok in my log. But I wanted to be sure. Jonathon Link to comment Share on other sites More sharing options...
Larry Posted June 17, 2013 Share Posted June 17, 2013 I don't know offhand if that'd be a problem. You can test it to confirm. But my inclination would be to either send a string or an array of strings. There's really no reason to do it this way (now that you've caught it). Link to comment Share on other sites More sharing options...
Antonio Conte Posted June 17, 2013 Share Posted June 17, 2013 It works because the query builder alters your input to work in several different forms. As long as the input is either: a.) A String that is a DB expression, i.e has parenthesis. COUNT(something)... or b.) Is a String (that will be exploded to an array first thing), or an array with elements that validates a regular expression... ...It will work. All valid elements found in your array will be kept, and the invalid ones removed. If it's an array, all valid elements will be exploded into a single String in the end. The "magic" here is obviously the regular expression, that is smart enough to judge your single array element of several DB columns as valid input. https://github.com/yiisoft/yii/blob/1.1.13/framework/db/CDbCommand.php#L603 Link to comment Share on other sites More sharing options...
Jonathon Posted June 17, 2013 Author Share Posted June 17, 2013 Thanks guys. I will revert it back to how the docs specify it though. But i'll be less concerned of it being a problem if i missed any more. Although I will check. Thanks Larry and Thomas Jonathon Link to comment Share on other sites More sharing options...
Recommended Posts