PHP Method Schema::getFields, someline-starter Code Examples

This page contains top rated real world PHP examples of method Schema::getFields from package someline-starter extracted from open source projects. You can rate examples to help us improve the quality of examples
Frequently Used Methods
Example #1
Show file File: Query.php Project: houdunwang/hdphp
0
 /**
  * 设置表
  *
  * @param $table
  *
  * @return $this
  */
 public function table($table)
 {
     //模型实例时不允许改表名
     $this->table = $this->table ?: c('database.prefix') . $table;
     //缓存表字段
     $this->fields = \Schema::getFields($table);
     //获取表主键
     $this->primaryKey = \Schema::getPrimaryKey($table);
     return $this;
 }
Example #2
Show file File: DataSet.php Project: fieg/knn
0
 /**
  * Calculates distances
  *
  * @param Node   $node
  * @param Node[] $neighbors
  */
 protected function calculateDistances(Node $node, array $neighbors)
 {
     $this->calculateRanges();
     foreach ($neighbors as $neighbor) {
         $deltas = array();
         foreach ($this->schema->getFields() as $field) {
             list($min, $max) = $this->ranges[$field];
             $range = $max - $min;
             $delta = $neighbor->get($field) - $node->get($field);
             $delta = $delta / $range;
             $deltas[$field] = $delta;
         }
         $total = 0;
         foreach ($deltas as $delta) {
             $total += $delta * $delta;
         }
         $neighbor->setDistance(sqrt($total));
     }
 }