本文整理汇总了PHP中site::all方法的典型用法代码示例。如果您正苦于以下问题:PHP site::all方法的具体用法?PHP site::all怎么用?PHP site::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类site
的用法示例。
在下文中一共展示了site::all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
function create()
{
$users = user::all();
$data['users'] = $users;
$sites = site::all();
$data['sites'] = $sites;
$this->view('sites/create_view.php', $data, 'main_template.php');
}
示例2: create
function create()
{
$user_id = $_GET['user_id'];
$user = user::from_id($user_id);
$user->accounts = account::from_user($user->user_id);
$sites = site::all();
foreach ($sites as $key => $site) {
foreach ($user->accounts as $account) {
if ($account->site_id == $site->site_id) {
unset($sites[$key]);
}
}
}
$data['sites'] = $sites;
$this->view('accounts/create_view.php', $data, 'main_template.php');
}
示例3: home
function home()
{
$masters = master::all();
$data['masters'] = $masters;
$data['total'] = 0;
foreach ($masters as $master) {
$data['total'] += $master->cash;
}
$users = user::all();
foreach ($users as $user) {
$user->accounts = account::from_user($user->user_id);
$bets = array();
$user->calculation['cash_in'] = 0;
$user->calculation['cash_out'] = 0;
$user->calculation['bonus'] = 0;
foreach ($user->accounts as $account) {
# räkna ut alla pengar
$account->transactions = transaction::from_account($account->account_id);
foreach ($account->transactions as $transaction) {
$transactions[] = $transaction;
if ($transaction->type == "cash_in") {
$user->calculation['cash_in'] += $transaction->amount;
} elseif ($transaction->type == "bonus") {
$user->calculation['bonus'] += $transaction->amount;
} elseif ($transaction->type == "cash_out") {
$user->calculation['cash_out'] -= $transaction->amount;
}
}
$account->cash();
}
}
$data['users'] = $users;
$sites = site::all();
$data['sites'] = $sites;
$matches = match::all_active();
$data['matches'] = $matches;
$this->view('index_view.php', $data, 'main_template.php');
}
示例4: catch
$stmt->execute();
$row = $stmt->fetchall(PDO::FETCH_CLASS, 'site');
return $row;
} catch (PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
}
function create()
{
try {
$conn = new PDO(PDOCONNECT, PDOUSERNAME, PDOPASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare('INSERT INTO sites SET name=:name,comment=:comment');
$stmt->execute(array("name" => $this->name, "comment" => $this->comment));
return $conn->lastInsertId();
} catch (PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
}
}
if (isset($_GET['c']) && $_GET['c'] == "create") {
$site = new site();
$site->name = $_POST['name'];
$site->comment = $_POST['comment'];
$id = $site->create();
return $id;
} elseif (isset($_GET['c']) && $_GET['c'] == "all") {
$sites = site::all();
echo json_encode($sites);
exit;
}