本文整理汇总了PHP中Accounts::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Accounts::get方法的具体用法?PHP Accounts::get怎么用?PHP Accounts::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Accounts
的用法示例。
在下文中一共展示了Accounts::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getByTag
function getByTag($count = 10, $from = "", $to = "", $account = "", $tag = "", $orderby = "", $order = "")
{
//Connect
$sql = new DataBase();
$sql->connect();
//Query
$query = "\r\n\t\t\tSELECT tht.transaction_id, tht.tag_id , transaction.*\r\n\t\t\tFROM transactions_has_tags tht, transactions transaction\r\n\t\t\tWHERE tht.tag_id = '" . $tag . "' AND transaction.id = tht.transaction_id ";
if (!empty($from)) {
$query .= "AND transaction.date >= '" . $from . "' ";
}
if (!empty($to)) {
$query .= "AND transaction.date <= '" . $to . "' ";
}
if (!empty($account)) {
$query .= "AND (transaction.account_from_id = '" . $account . "' || transaction.account_to_id = '" . $account . "') ";
}
if (!empty($id)) {
$query .= "AND transaction.id = '" . $id . "' ";
}
if ($orderby == 'date') {
$query .= " ORDER BY transaction.date ";
}
if ($order == "ASC") {
$query .= "ASC ";
}
if ($order == "DESC") {
$query .= "DESC ";
}
$sql->query($query);
//Objects
$json = array();
//Instances
$tags = new Tags();
$accounts = new Accounts();
//Data
while ($data = mysql_fetch_array($sql->result)) {
$array = array("id" => $data["id"], "description" => $data["description"], "amount" => $data['transaction_type_id'] == 3 && $data["account_from_id"] != $account ? $data["amount"] * -1 : $data["amount"], "type" => $data["transaction_type_id"], "date" => $data["date"], "account_from" => $data["account_from_id"], "account_to" => $data["account_to_id"], "account_type" => $accounts->get(1, $data["account_from_id"], "account_type_id"), "profile_id" => $data["profile_id"], 'tags' => $tags->getTransactionTags(1000, $data["id"]));
array_push($json, $array);
}
//Close connection
//$sql->close();
//Return
return $json;
}
示例2: array
$sql->connect();
//Verify if exists
$tr = $transactions->get('all', '', '', '', $ID);
$data = $tr;
if (count($tr) == 0) {
RestUtils::sendResponse('406', array('data' => 'transactionId', 'message' => 'Essa transação não existe.'));
}
if ($tr[0]['profile_id'] != CurrentUser::getId()) {
RestUtils::sendResponse('406', array('data' => 'transactionId', 'message' => 'Essa transação não pertence ao perfil.'));
}
//Remove
$sql->query("DELETE FROM transactions_has_tags WHERE transaction_id = '" . $ID . "'");
$sql->query("DELETE FROM transactions WHERE id = '" . $ID . "'");
//Remove in Ammount
if ($data[0]['account_to'] != '') {
$balance = $accounts->get(1, $data[0]['account_from'], 'balance');
$balance += $data[0]['amount'];
$sql->query("UPDATE accounts SET balance='" . $balance . "' WHERE id = '" . $data[0]['account_from'] . "'");
$balance = $accounts->get(1, $data[0]['account_to'], 'balance');
$balance -= $data[0]['amount'];
$sql->query("UPDATE accounts SET balance='" . $balance . "' WHERE id = '" . $data[0]['account_to'] . "'");
} else {
$balance = $accounts->get(1, $data[0]['account_from'], 'balance');
$balance -= $data[0]['amount'];
$sql->query("UPDATE accounts SET balance='" . $balance . "' WHERE id = '" . $data[0]['account_from'] . "'");
}
//Close Connection
$sql->close();
RestUtils::sendResponse('200');
break;
/*
示例3: elseif
//GET types
if ($_DATA['id'] == 'types') {
echo json_encode($accounts->getTypes());
exit;
//Get Balance
} elseif ($_DATA['id'] == 'balance') {
isset($_DATA['account']) ? $account = $_DATA['account'] : ($account = "");
isset($_DATA['year']) ? $year = $_DATA['year'] : ($year = "");
isset($_DATA['month']) ? $month = $_DATA['month'] : ($month = "");
isset($_DATA['orderBy']) ? $orderBy = $_DATA['orderBy'] : ($orderBy = "year");
isset($_DATA['order']) ? $order = $_DATA['order'] : ($order = "DESC");
echo json_encode($accounts->getBalance($account, $month, $year, $orderBy, $order));
exit;
//Get info of one account
} else {
echo json_encode($accounts->get(1, $_DATA['id']));
exit;
}
//Get ALL
} else {
isset($_DATA['count']) ? $count = intval($_DATA['count']) : ($count = 50);
echo json_encode($accounts->get($count));
exit;
}
break;
/*
* ======================================
* PUT method
* ======================================
*/
/*