Welcome Guest, Not a member yet? Register   Sign In
find Multiple Column in Model
#1

I create a category model and ı want to choose three column. but findColumn Method permission this.
it's say [font=Lato, proxima-nova,]$column_name should be a name of single column else you will get the DataException.[/font]

[font=Lato, proxima-nova,]Do you suggest try modify this function


[font=Consolas]public function findColumn(string $columnName)
{
  if (strpos($columnName',') !== false)
  {
      throw DataException::forFindColumnHaveMultipleColumns();
  }

  $resultSet $this->select($columnName)
                ->asArray()
                ->find();

  return (! empty($resultSet)) ? array_column($resultSet$columnName) : null;
}
[/font]
[/font]



[font=Lato, proxima-nova,][font=Consolas]for example [/font][/font]

[font=Lato, proxima-nova,][font=Consolas][font=Consolas]public function findColumnAll(array $columnName)
{
[/font]
[/font]
[/font]

[font=Lato, proxima-nova,][font=Consolas][font=Consolas][font=Consolas]$selectString="";[/font][/font][/font][/font]
[font=Lato, proxima-nova,][font=Consolas][font=Consolas]  foreach($[font=Consolas]columnName as $k=>$v){[/font][/font][/font][/font]
[font=Lato, proxima-nova,][font=Consolas][font=Consolas][font=Consolas]  [/font][/font][/font][/font]
[font=Lato, proxima-nova,][font=Consolas][font=Consolas][font=Consolas]   $selectString.=$v;[/font][/font][/font][/font]
[font=Lato, proxima-nova,][font=Consolas][font=Consolas][font=Consolas]   }

  $resultSet $this->select($selectString)
                ->asArray()
                ->find();

  return (! empty($resultSet)) ? $resultSet : null;
}[/font]
[/font]
[/font]
[/font]

What do you think About This ??? [font=Tahoma, Verdana, Arial, sans-serif]Does it cause any problem  Huh Huh [/font]
Sercan YANBULOGLU
SEO links REDACTED, per forum policy
Reply




Theme © iAndrew 2016 - Forum software by © MyBB