Ejemplo n.º 1
0
 public function editAction()
 {
     //$this->_helper->viewRenderer->setNoRender(true);
     $referer = $this->getRequest()->getHeader('Referer');
     $id = $this->getParam('id');
     $userForm = new Form_Auth_Add();
     try {
         #using named parameters
         /*
         $sql = 'SELECT * FROM users WHERE id = :id';
         $stmt = new Zend_Db_Statement_Pdo($this->db, $sql);
         $stmt->execute(array(':id' => $this->getParam('id')));
         */
         #using positional parameters
         $sql = 'SELECT * FROM users WHERE id = ?';
         $stmt = new Zend_Db_Statement_Pdo($this->db, $sql);
         $stmt->execute(array($id));
         $userData = $stmt->fetchAll();
         if ($this->getRequest()->isPost()) {
             print_r($usersData);
             exit;
             // clearing previous values
             $usersData = array();
             $userData = $this->getRequest()->getPost();
             if ($userForm->isValid($userData)) {
                 $this->db->update($userData, 'id = ' . (int) $id);
                 $this->_redirect($referer);
             }
         }
         $userForm->populate($userData);
         print_r($userData[0]);
         //exit;
         //$this->view->users = $usersData; // oneliner // $this->view->users = $this->db->fetchAll($sql);
         $this->view->userForm = $userForm;
         // oneliner // $this->view->users = $this->db->fetchAll($sql);
     } catch (Exception $e) {
         $this->_helper->flashMessenger('An error_log');
     }
 }
Ejemplo n.º 2
0
    public function getFirstOrLastLogForUser($idUser, $first = true)
    {
        $db = $this->getDbTable()->getAdapter();
        $sql = '	SELECT *
					FROM pic 
					WHERE user_id = :idUser
					';
        if ($first) {
            $sql .= ' ORDER BY date_shot DESC LIMIT 1';
        } else {
            $sql .= ' ORDER BY date_shot ASC LIMIT 1';
        }
        $stmt = new Zend_Db_Statement_Pdo($db, $sql);
        $stmt->bindParam(':idUser', $idUser);
        $stmt->execute();
        $resultSet = $stmt->fetchAll();
        $arrPics = $this->createObjektArr($resultSet);
        if (empty($arrPics)) {
            return 0;
        } else {
            return $arrPics[0];
        }
    }
Ejemplo n.º 3
0
 /**
  * Create default timeslot values based on days/session duration
  *
  * @param	array	$post	Post request
  */
 public function createTimeslots($post)
 {
     $db = $this->getAdapter();
     $dt = new Zend_Date($post['start'], 'dd/MM/YYYY hh:mm');
     $sql = 'insert into timeslots (tstart, tend, number, type, conference_id)' . 'values (:tstart, :tend, :number, :type, ' . (int) $post['id'] . ')';
     $stmt = new Zend_Db_Statement_Pdo($db, $sql);
     $n = 0;
     // for every day add slot/break/lunch/slot/break/slot
     for ($i = 1; $i <= $post['days']; $i++) {
         $stmt->execute(array(':tstart' => $dt->get(Zend_Date::ISO_8601), ':tend' => $dt->add('90', 'mm')->get(Zend_Date::ISO_8601), ':number' => $n + 1, ':type' => 1));
         $stmt->execute(array(':tstart' => $dt->get(Zend_Date::ISO_8601), ':tend' => $dt->add('30', 'mm')->get(Zend_Date::ISO_8601), ':number' => 0, ':type' => 2));
         $stmt->execute(array(':tstart' => $dt->get(Zend_Date::ISO_8601), ':tend' => $dt->add('90', 'mm')->get(Zend_Date::ISO_8601), ':number' => $n + 2, ':type' => 1));
         $stmt->execute(array(':tstart' => $dt->get(Zend_Date::ISO_8601), ':tend' => $dt->add('90', 'mm')->get(Zend_Date::ISO_8601), ':number' => 0, ':type' => 3));
         $stmt->execute(array(':tstart' => $dt->get(Zend_Date::ISO_8601), ':tend' => $dt->add('90', 'mm')->get(Zend_Date::ISO_8601), ':number' => $n + 3, ':type' => 1));
         $stmt->execute(array(':tstart' => $dt->get(Zend_Date::ISO_8601), ':tend' => $dt->add('30', 'mm')->get(Zend_Date::ISO_8601), ':number' => 0, ':type' => 2));
         $stmt->execute(array(':tstart' => $dt->get(Zend_Date::ISO_8601), ':tend' => $dt->add('90', 'mm')->get(Zend_Date::ISO_8601), ':number' => $n = $n + 4, ':type' => 1));
         // reset date and add a day
         $dt = new Zend_Date($post['start'], 'dd/MM/YYYY hh:mm');
         $dt->add($i, Zend_Date::DAY_SHORT);
     }
     return true;
 }
Ejemplo n.º 4
0
 function insertAllSessionData($session_date, $records)
 {
     $db = Zend_Registry::get('db');
     $i = 0;
     $max_inserts = 100;
     for ($rows = 0; $rows < count($records); $rows += $max_inserts) {
         $values = array();
         $sql = 'INSERT INTO t_exercise_data
                    (session_date,
                     time,
                     distance,
                     heartrate,
                     speed,
                     latitude,
                     longitude,
                     altitude,
                     cadence,
                     temperature,
                     power,
                     gradient,
                     userid)
                 VALUES ';
         /* Do a multi insert */
         for ($i = 0; $i < $max_inserts && $i + $rows < count($records); $i++) {
             if ($i != 0) {
                 $sql .= ', ';
             }
             $sql .= '(:session_date,
                       :time' . $i . ',
                       :distance' . $i . ',
                       :heartrate' . $i . ',
                       :speed' . $i . ',
                       :latitude' . $i . ',
                       :longitude' . $i . ',
                       :altitude' . $i . ',
                       :cadence' . $i . ',
                       :temperature' . $i . ',
                       :power' . $i . ',
                       :gradient' . $i . ',
                       :userid) ';
             $values[':time' . $i] = $records[$i + $rows]->interval;
             $values[':distance' . $i] = $records[$i + $rows]->distance;
             $values[':heartrate' . $i] = $records[$i + $rows]->heart_rate;
             $values[':speed' . $i] = $records[$i + $rows]->speed;
             $values[':latitude' . $i] = $records[$i + $rows]->position_lat;
             $values[':longitude' . $i] = $records[$i + $rows]->position_long;
             $values[':altitude' . $i] = $records[$i + $rows]->altitude;
             $values[':cadence' . $i] = $records[$i + $rows]->cadence;
             $values[':temperature' . $i] = $records[$i + $rows]->temperature;
             $values[':power' . $i] = $records[$i + $rows]->power;
             $values[':gradient' . $i] = $records[$i + $rows]->gradient;
         }
         //$stmt = new Zend_Db_Statement($db, $sql);
         $stmt = new Zend_Db_Statement_Pdo($db, $sql);
         /* Add the constant values for all rows */
         $values[':session_date'] = $session_date;
         $values[':userid'] = Core_Common::getCurrentUserLogin();
         $stmt->execute($values);
     }
 }
Ejemplo n.º 5
0
    public function searchFriendsByName($idUser, $username)
    {
        $db = $this->getDbTable()->getAdapter();
        $sql = '	SELECT 	f.*
					FROM 	user f, 
							user_friends u 
					WHERE 	u.id_user = :idUser
					AND 	f.id = u.id_friend	
					AND		f.username LIKE :name ';
        $username = '******' . $username . '%';
        $stmt = new Zend_Db_Statement_Pdo($db, $sql);
        $stmt->bindParam(':idUser', $idUser);
        $stmt->bindParam(':name', $username);
        $stmt->execute();
        $resultSet = $stmt->fetchAll();
        $arrRestaurants = $this->createObjektArr($resultSet);
        return $arrRestaurants;
    }