本文整理汇总了PHP中model::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP model::getTable方法的具体用法?PHP model::getTable怎么用?PHP model::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model
的用法示例。
在下文中一共展示了model::getTable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: includes
/**
* Itterate over object, build a relations, fillable and includes collection.
*
* @param model $object the model to iterate over
*
* @return array
*/
private function includes($object)
{
$fillable = $object->getFillable();
$includes = $object->getIncludes();
$table = $object->getTable();
$columns = $object->columns();
$results[$table] = [];
if (!empty($includes)) {
foreach ($includes as $include) {
$results[$table] = ['object' => $object, 'includes' => $this->includes(new $include())];
}
}
$this->fillables->put($table, $fillable);
$this->includes->push($table, $table);
$this->columns->put($table, $columns);
return $results;
}
示例2: getAvgQuery
/**
* build the query for the avg caclculation - can be overwritten in plugin class (see date element for eg)
* @param model $listModel
* @param string $label the label to apply to each avg
* @return string sql statement
*/
protected function getAvgQuery(&$listModel, $label = "'calc'")
{
$table =& $listModel->getTable();
$joinSQL = $listModel->_buildQueryJoin();
$whereSQL = $listModel->_buildQueryWhere();
$name = $this->getFullName(false, false, false);
return "SELECT FROM_UNIXTIME(AVG(UNIX_TIMESTAMP({$name}))) AS value, {$label} AS label FROM `{$table->db_table_name}` {$joinSQL} {$whereSQL}";
}
示例3: getAvgQuery
/**
* build the query for the avg caclculation - can be overwritten in plugin class (see date element for eg)
* @param model $listModel
* @param string $label the label to apply to each avg
* @return string sql statement
*/
protected function getAvgQuery(&$listModel, $label = "'calc'")
{
$item = $listModel->getTable();
$joinSQL = $listModel->_buildQueryJoin();
$whereSQL = $listModel->_buildQueryWhere();
$name = $this->getFullName(false, false, false);
$groupModel = $this->getGroup();
$roundTo = (int) $this->getParams()->get('avg_round');
if ($groupModel->isJoin()) {
//element is in a joined column - lets presume the user wants to sum all cols, rather than reducing down to the main cols totals
return "SELECT ROUND(AVG({$name}), {$roundTo}) AS value, {$label} AS label FROM " . FabrikString::safeColName($item->db_table_name) . " {$joinSQL} {$whereSQL}";
} else {
// need to do first query to get distinct records as if we are doing left joins the sum is too large
return "SELECT ROUND(AVG(value), {$roundTo}) AS value, label\nFROM (SELECT DISTINCT {$item->db_primary_key}, {$name} AS value, {$label} AS label FROM " . FabrikString::safeColName($item->db_table_name) . " {$joinSQL} {$whereSQL}) AS t";
}
}
示例4: getMedianQuery
/**
* build the query for the avg caclculation
* @param model $listModel
* @param string $label the label to apply to each avg
* @return string sql statement
*/
protected function getMedianQuery(&$listModel, $label = "'calc'")
{
$fields = $listModel->getDBFields($this->getTableName(), 'Field');
if ($fields[$this->getElement()->name]->Type == 'time') {
$name = $this->getFullName(false, false, false);
$table =& $listModel->getTable();
$joinSQL = $listModel->_buildQueryJoin();
$whereSQL = $listModel->_buildQueryWhere();
return "SELECT SEC_TO_TIME(TIME_TO_SEC({$name})) AS value, {$label} AS label FROM `{$table->db_table_name}` {$joinSQL} {$whereSQL}";
} else {
return parent::getMedianQuery($listModel, $label);
}
}
示例5: getMedianQuery
/**
* build the query for the avg caclculation - can be overwritten in plugin class (see date element for eg)
* @param model $tableModel
* @param string $label the label to apply to each avg
* @return string sql statement
*/
protected function getMedianQuery(&$tableModel, $label = "'calc'")
{
$table =& $tableModel->getTable();
$joinSQL = $tableModel->_buildQueryJoin();
$whereSQL = $tableModel->_buildQueryWhere();
$name = $this->getFullName(false, false, false);
//return "SELECT DATE_FORMAT(FROM_UNIXTIME((UNIX_TIMESTAMP($name))), '%H:%i:%s') AS value, $label AS label FROM `$table->db_table_name` $joinSQL $whereSQL";
return "SELECT SEC_TO_TIME(TIME_TO_SEC({$name})) AS value, {$label} AS label FROM `{$table->db_table_name}` {$joinSQL} {$whereSQL}";
}
示例6: getAvgQuery
/**
* build the query for the avg caclculation - can be overwritten in plugin class (see date element for eg)
* @param model $tableModel
* @param string $label the label to apply to each avg
* @return string sql statement
*/
protected function getAvgQuery(&$tableModel, $label = "'calc'")
{
$table =& $tableModel->getTable();
$joinSQL = $tableModel->_buildQueryJoin();
$whereSQL = $tableModel->_buildQueryWhere();
$name = $this->getFullName(false, false, false);
$groupModel =& $this->getGroup();
if ($groupModel->isJoin()) {
//element is in a joined column - lets presume the user wants to sum all cols, rather than reducing down to the main cols totals
return "SELECT ROUND(AVG({$name})) AS value, {$label} AS label FROM " . FabrikString::safeColName($table->db_table_name) . " {$joinSQL} {$whereSQL}";
} else {
// need to do first query to get distinct records as if we are doing left joins the sum is too large
//return "SELECT ROUND(AVG(value)) AS value, label FROM (SELECT DISTINCT ".FabrikString::safeColName($table->db_table_name.'.'.$table->db_primary_key).", $name AS value, $label AS label FROM ".FabrikString::safeColName($table->db_table_name)." $joinSQL $whereSQL) AS t";
return "SELECT ROUND(AVG(value)) AS value, label FROM (SELECT DISTINCT " . FabrikString::safeColName($table->db_table_name . '.' . $table->db_primary_key) . ", {$name} AS value, {$label} AS label FROM " . FabrikString::safeColName($table->db_table_name) . " {$joinSQL} {$whereSQL}) AS t";
}
}