/** * Get first row of data selected by where clause **/ public function first() { if (!empty($this->data)) { if (Table::count($this->data) > 0) { return $this->data[0]; } else { return null; } } else { return null; } }
public static function join($array, $separator, $startIndex = 0, $count = -1) { $string = ""; // $end = $count == -1 ? Table::count($array) : $count; // for ($i = $startIndex; $i < $end; $i++) { if ($i == $end - 1) { $string .= $array[$i]; } else { echo $string .= $array[$i] . $separator; } } // return $string; }
/** * preparing the data for the hasone relation * @param $model : data of the raltion * @param $remote : the model wanted to be related to the * current model */ protected function prepare($model, $remote) { return !empty($model) ? isset($model->data) ? Table::count($model->data) == 1 ? $model->data[0] : $this->ManyRelationException($remote) : null : null; }
/** * preparing the data for the hasone relation * @param $model : data of the raltion * @param $remote : the model wanted to be related to the * current model */ protected function prepare($models) { return !is_null($models->data) ? Table::count($models->data) > 0 ? Table::count($models->data) == 1 ? $models->data[0] : $models->data : null : null; }
protected static function getSchemas($root) { $f = glob($root . 'app/schemas/*.php'); $sch = array(); // foreach ($f as $value) { $t = explode("/", $value); $t = $t[Table::count($t) - 1]; $t = explode(".php", $t); $t = $t[0]; $sch[] = $t; } // return $sch; }