本文整理汇总了PHP中BaseModel::GetAccountInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseModel::GetAccountInfo方法的具体用法?PHP BaseModel::GetAccountInfo怎么用?PHP BaseModel::GetAccountInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseModel
的用法示例。
在下文中一共展示了BaseModel::GetAccountInfo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Index
public function Index()
{
parent::GetAccountInfo();
//get all commands
$sql = "SELECT * FROM commands";
if ($stmt = $this->database->prepare($sql)) {
$stmt->execute();
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
$this->view->commands = $row;
$stmt->closeCursor();
}
//get current state command id
$command_id = null;
$sql = "SELECT command_id FROM state LIMIT 1";
if ($stmt = $this->database->prepare($sql)) {
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$command_id = $row['command_id'];
$stmt->closeCursor();
}
//get current command
$sql = "SELECT * FROM commands WHERE id=:command_id";
if ($stmt = $this->database->prepare($sql)) {
$stmt->bindParam(':command_id', $command_id, PDO::PARAM_STR);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$this->view->current_command = $row;
$stmt->closeCursor();
}
}
示例2: AddToWatchList_POST
public function AddToWatchList_POST($event_id)
{
parent::GetAccountInfo();
//Check if event is already on watchlist
$sql = "SELECT * FROM watchlist WHERE event_id=:event_id AND user_id=:user_id LIMIT 1";
if ($stmt = $this->database->prepare($sql)) {
$stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
$stmt->bindParam(':user_id', $this->view->account->id, PDO::PARAM_STR);
$stmt->execute();
$row = $stmt->fetch(PDO::PARAM_STR);
if ($row) {
echo json_encode("exists");
exit;
}
}
//Add to watchlist
$sql = "INSERT INTO watchlist (event_id, user_id, created, updated) VALUES (:event_id, :user_id, NOW(), NOW())";
if ($stmt = $this->database->prepare($sql)) {
$stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
$stmt->bindParam(':user_id', $this->view->account->id, PDO::PARAM_STR);
$stmt->execute();
$stmt->closeCursor();
$this->notification = array();
//Create notification
$notification = array("user_id" => $this->view->account->id, "type" => NotificationType::AddedToWatchList, "title" => NotificationType::AddedToWatchList, "content" => 'You added an <a href=/event/detail/' . $event_id . '>event</a> to your WatchList');
parent::AddNotification($notification);
echo json_encode("success");
exit;
}
}
示例3: DeleteCommand_POST
public function DeleteCommand_POST()
{
//Get current user account info
parent::GetAccountInfo();
//Get posted fields
$this->view->post = array('id' => $_POST['id']);
//Insert record
$sql = "DELETE FROM commands\n WHERE id=:id";
if ($stmt = $this->database->prepare($sql)) {
$stmt->bindParam(':id', $this->view->post['id'], PDO::PARAM_STR);
$stmt->execute();
$stmt->closeCursor();
}
}
示例4: GetUnSeenCount_POST
public function GetUnSeenCount_POST()
{
parent::GetAccountInfo();
$sql = "SELECT id FROM notifications WHERE user_id=:user_id AND has_seen=0";
if ($stmt = $this->database->prepare($sql)) {
$stmt->bindParam(':user_id', $this->view->account->id, PDO::PARAM_STR);
$stmt->execute();
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(count($row));
exit;
}
}
示例5: Run
public function Run()
{
parent::GetAccountInfo();
$sampleKeywords = array('cosy', 'rustic', 'modern', 'old', 'quiet', 'refurbished', 'farm', 'peaceful', 'zen', 'rural', 'original', 'big', 'small');
$count = 10;
$sampleEvents = array();
//locations
$locations = array('43 Main Street, Toronto, Canada, CA12 EFJ', '21 Some Road, Toronto, Canada, CA12 7ET', '828 Big Close, Toronto, Canada, CA12 5JD', '18 Small Lane, Toronto, Canada, CA12 9DJ', '98 Barvas Walk, Toronto, Canada, CA12 3DF', '23 Stronsey Drive, Toronto, Canada, CA12 9DN', '39 Kincorth Avenue, Toronto, Canada, CA12 2JF', '4339 Union Street, Toronto, Canada, CA12 2ED', '323 Tarrensay Square, Toronto, Canada, CA12 6FN', '849 MadeUp Road, Toronto, Canada, CA12 8FJ');
//names
$names = array('Event Sample Name #1', 'Event Sample Name #2', 'Event Sample Name #3', 'Event Sample Name #4', 'Event Sample Name #5', 'Event Sample Name #6', 'Event Sample Name #7', 'Event Sample Name #8', 'Event Sample Name #9', 'Event Sample Name #10');
//descriptions
$descriptions = array("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.");
$dates = array(array('date' => '2015-10-10', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-10', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-12', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-13', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-14', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-15', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-16', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-18', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-18', 'start_time' => '09:00:00', 'end_time' => '11:00:00'), array('date' => '2015-10-18', 'start_time' => '09:00:00', 'end_time' => '11:00:00'));
//Generate sample events
for ($i = 0; $i < $count; $i++) {
array_push($sampleEvents, $this->CreateSampleEvent($locations[$i], $names[$i], $descriptions[$i]));
}
//echo '<pre>'; print_r($sampleEvents); exit();
$count = 0;
$event_id = null;
$insertedImageId = null;
//Create events
foreach ($sampleEvents as $event) {
$sql = "INSERT INTO events (user_id,\n location,\n currency,\n price,\n bedrooms,\n bathrooms,\n type,\n name,\n description,\n privacy,\n created,\n updated) VALUES (:user_id,\n :location,\n 'CAD',\n :price,\n :bedrooms,\n :bathrooms,\n :type,\n :name,\n :description,\n :privacy,\n NOW(),\n NOW()\n )";
if ($stmt = $this->database->prepare($sql)) {
$stmt->bindParam(':user_id', $event['user_id'], PDO::PARAM_STR);
$stmt->bindParam(':location', $event['location'], PDO::PARAM_STR);
$stmt->bindParam(':price', $event['price'], PDO::PARAM_STR);
$stmt->bindParam(':bedrooms', $event['bedrooms'], PDO::PARAM_STR);
$stmt->bindParam(':bathrooms', $event['bathrooms'], PDO::PARAM_STR);
$stmt->bindParam(':type', $event['type'], PDO::PARAM_STR);
$stmt->bindParam(':name', $event['name'], PDO::PARAM_STR);
$stmt->bindParam(':description', $event['description'], PDO::PARAM_STR);
$stmt->bindParam(':privacy', $event['privacy'], PDO::PARAM_STR);
$stmt->execute();
$event_id = $this->database->lastInsertId();
}
$sql = "INSERT INTO event_dates (event_id, date, start_time, end_time) VALUES (:event_id, :date, :start_time, :end_time)";
if ($stmt = $this->database->prepare($sql)) {
$stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
$stmt->bindParam(':date', $dates[rand(0, count($dates) - 1)]['date'], PDO::PARAM_STR);
$stmt->bindParam(':start_time', $dates[rand(0, count($dates) - 1)]['start_time'], PDO::PARAM_STR);
$stmt->bindParam(':end_time', $dates[rand(0, count($dates) - 1)]['end_time'], PDO::PARAM_STR);
$stmt->execute();
}
$sql = "INSERT INTO event_dates (event_id, date, start_time, end_time) VALUES (:event_id, :date, :start_time, :end_time)";
if ($stmt = $this->database->prepare($sql)) {
$stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
$stmt->bindParam(':date', $dates[rand(0, count($dates) - 1)]['date'], PDO::PARAM_STR);
$stmt->bindParam(':start_time', $dates[rand(0, count($dates) - 1)]['start_time'], PDO::PARAM_STR);
$stmt->bindParam(':end_time', $dates[rand(0, count($dates) - 1)]['end_time'], PDO::PARAM_STR);
$stmt->execute();
}
//
//INSERT EVENT_KEYWORDS
//
$sql = "INSERT INTO event_keywords (event_id, tag) VALUES (:event_id, :tag)";
if ($stmt = $this->database->prepare($sql)) {
$stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
$stmt->bindParam(':tag', $sampleKeywords[rand(0, count($sampleKeywords) - 1)], PDO::PARAM_STR);
$stmt->execute();
}
if ($stmt = $this->database->prepare($sql)) {
$stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
$stmt->bindParam(':tag', $sampleKeywords[rand(0, count($sampleKeywords) - 1)], PDO::PARAM_STR);
$stmt->execute();
}
if ($stmt = $this->database->prepare($sql)) {
$stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
$stmt->bindParam(':tag', $sampleKeywords[rand(0, count($sampleKeywords) - 1)], PDO::PARAM_STR);
$stmt->execute();
}
//
//INSERT IMAGES AND EVENT_IMAGES
//
for ($i = 0; $i < 3; $i++) {
$image = rand(1, 3) . '.jpg';
$sql = "INSERT INTO event_images (event_id, href, created, updated) VALUES (:event_id, :href, NOW(), NOW())";
if ($stmt = $this->database->prepare($sql)) {
$href = '/public/app_data/event_images/' . $image;
$stmt->bindParam(':event_id', $event_id, PDO::PARAM_STR);
$stmt->bindParam(':href', $href, PDO::PARAM_STR);
$stmt->execute();
}
}
$count++;
}
}