示例#1
0
 /**
  * @param $query string
  * @return string[]|null
  */
 private function guessContext($query)
 {
     $context = [];
     // first clause between `...` is probably the name of the table
     $table_name = mParse($query, BQ, BQ);
     if ($table_name) {
         $class_name = Dao::classNameOf($table_name);
         if ($class_name) {
             $context[] = $class_name;
         }
     }
     // every JOIN `...` may be the name of a table
     $joins = explode('JOIN ' . BQ, $query);
     array_shift($joins);
     foreach ($joins as $join) {
         $table_name = lParse($join, BQ);
         if ($table_name) {
             $class_name = Dao::classNameOf($table_name);
             if ($class_name) {
                 $context[] = $class_name;
             }
         }
     }
     return $context ? $context : null;
 }