function getNextIndex($counterName) { $bind = ['counterName' => $counterName]; $query = 'CALL getCounterNextIndex(:counterName)'; $res = $this->db->run($query, $bind, ['fetch' => true]); return $res[0]['lastIndex']; }
public function updateUser(array $userData) { $user = new User($userData); $userId = $user->getUserId(); if (empty($userId)) { return Notification::error('UserId is empty'); } if (empty($user->getUserName())) { $user->setUserName('user' . App::getCounterNextIndex('user')); } $userTableUpdate = $this->db->update('users', $user->toArray(), 'userId = :userId', ['userId' => $userId]); if ($userTableUpdate) { switch ($user->getRole()) { case Defines::ROLE_DOCTOR: $doctor = new User($userData); return $this->db->update('doctors', $doctor->toArray(), 'doctorId = :userId', ['userId' => $userId]); case Defines::ROLE_CLIENT: $client = new User($userData); return $this->db->update('clients', $client->toArray(), 'clientId = :userId', ['userId' => $userId]); } } return false; }
function updateOrderDates($orderId, \DateTime $start, \DateTime $end) { $data = ['start' => $start->format('Y-m-d H:i:s'), 'end' => $end->format('Y-m-d H:i:s')]; $bind = ['partnerId' => Config::getInstance()->partnerId, 'orderId' => $orderId]; return $this->db->update('orders', $data, 'partnerId = :partnerId AND orderId = :orderId', $bind); }
public function deleteDayWorkingTimes($doctorId, \DateTime $date) { $bind = ['partnerId' => Config::getInstance()->partnerId, 'doctorId' => $doctorId, 'date' => $date->format('Y-m-d')]; $where = 'partnerId = :partnerId AND doctorId = :doctorId AND date = :date'; return $this->db->delete('workingTimes', $where, $bind); }