protected function resetSharedConn()
 {
     if (self::$_sharedConn) {
         self::$_sharedConn->close();
         self::$_sharedConn = null;
     }
 }
Example #2
0
/**
 * Drop all existing tables, even those not defined in the schema.
 *
 * @param Doctrine\DBAL\Connection $connection
 */
function dropTables(Doctrine\DBAL\Connection $connection)
{
    $connection->query('SET FOREIGN_KEY_CHECKS=0');
    foreach ($connection->getSchemaManager()->listTableNames() as $table) {
        $connection->getSchemaManager()->dropTable($table);
    }
    $connection->query('SET FOREIGN_KEY_CHECKS=1');
}
Example #3
0
 public function getList()
 {
     $list = $this->db->fetchAll('SELECT id, nazov FROM predmety');
     $pair = array();
     foreach ($list as $predmet) {
         $pair[$predmet['id']] = $predmet['nazov'];
     }
     unset($list);
     return $pair;
 }
Example #4
0
 public function getList()
 {
     $list = $this->db->fetchAll('SELECT id, rocnik, kod FROM triedy');
     $pair = array();
     foreach ($list as $trieda) {
         $pair[$trieda['id']] = ($trieda['rocnik'] < 4 ? str_repeat('I', $trieda['rocnik']) : 'IV') . '. ' . $trieda['kod'];
     }
     unset($list);
     return $pair;
 }
 protected function resetSharedConn()
 {
     if ($this->sharedFixture['conn']) {
         $this->sharedFixture['conn']->close();
         $this->sharedFixture['conn'] = null;
     }
     if (self::$_sharedConn) {
         self::$_sharedConn->close();
         self::$_sharedConn = null;
     }
 }
Example #6
0
 public function auth(User $loginUser)
 {
     $imap = true;
     if (!$imap) {
         return FALSE;
     } else {
         if ($user = $this->db->fetchAssoc("SELECT p.id, p.heslo, p.meno, p.role, t.rocnik, t.kod, p.trieda_id FROM pouzivatelia AS p LEFT JOIN triedy AS t ON p.trieda_id = t.id WHERE p.login = ?", array($loginUser->getLogin()))) {
             return $user['heslo'] === md5($loginUser->getPassword()) ? $user : FALSE;
         } else {
             return FALSE;
         }
     }
 }
 /**
  * @param ClassMetadata $class
  * @param array         $entityData
  * @param string        $revType
  */
 private function saveRevisionEntityData($class, $entityData, $revType)
 {
     $params = array($this->getRevisionId(), $revType);
     $types = array(\PDO::PARAM_INT, \PDO::PARAM_STR);
     foreach ($class->fieldNames as $field) {
         $params[] = $entityData[$field];
         $types[] = $class->fieldMappings[$field]['type'];
     }
     foreach ($class->associationMappings as $field => $assoc) {
         if (($assoc['type'] & ClassMetadata::TO_ONE) > 0 && $assoc['isOwningSide']) {
             $targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
             if ($entityData[$field] !== null) {
                 $relatedId = $this->uow->getEntityIdentifier($entityData[$field]);
             }
             $targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
             foreach ($assoc['sourceToTargetKeyColumns'] as $sourceColumn => $targetColumn) {
                 if ($entityData[$field] === null) {
                     $params[] = null;
                     $types[] = \PDO::PARAM_STR;
                 } else {
                     $params[] = $relatedId[$targetClass->fieldNames[$targetColumn]];
                     $types[] = $targetClass->getTypeOfColumn($targetColumn);
                 }
             }
         }
     }
     $this->conn->executeUpdate($this->getInsertRevisionSQL($class), $params, $types);
 }
 /**
  * Creates a left join list for translations
  * on used query components
  *
  * @todo: make it cleaner
  * @return string
  */
 private function getTranslationJoinsSql()
 {
     $result = array();
     $em = $this->getEntityManager();
     $ea = new TranslatableEventAdapter();
     $locale = $this->listener->getListenerLocale();
     foreach ($this->translatedComponents as $dqlAlias => $comp) {
         if (!isset($result[$comp['nestingLevel']])) {
             $result[$comp['nestingLevel']] = '';
         }
         $meta = $comp['metadata'];
         $config = $this->listener->getConfiguration($em, $meta->name);
         $transClass = $this->listener->getTranslationClass($ea, $meta->name);
         $transMeta = $em->getClassMetadata($transClass);
         $transTable = $transMeta->getQuotedTableName($this->platform);
         foreach ($config['fields'] as $field) {
             $compTableName = $meta->getQuotedTableName($this->platform);
             $compTblAlias = $this->getSQLTableAlias($compTableName, $dqlAlias);
             $tblAlias = $this->getSQLTableAlias('trans' . $compTblAlias . $field);
             $sql = ' LEFT JOIN ' . $transTable . ' ' . $tblAlias;
             $sql .= ' ON ' . $tblAlias . '.' . $transMeta->getQuotedColumnName('locale', $this->platform) . ' = ' . $this->conn->quote($locale);
             $sql .= ' AND ' . $tblAlias . '.' . $transMeta->getQuotedColumnName('objectClass', $this->platform) . ' = ' . $this->conn->quote($meta->name);
             $sql .= ' AND ' . $tblAlias . '.' . $transMeta->getQuotedColumnName('field', $this->platform) . ' = ' . $this->conn->quote($field);
             $identifier = $meta->getSingleIdentifierFieldName();
             $colName = $meta->getQuotedColumnName($identifier, $this->platform);
             $colAlias = $this->getSQLColumnAlias($colName);
             $sql .= ' AND ' . $tblAlias . '.' . $transMeta->getQuotedColumnName('foreignKey', $this->platform) . ' = ' . $compTblAlias . '.' . $colName;
             $result[$comp['nestingLevel']] .= $sql;
             $this->replacements[$compTblAlias . '.' . $meta->getQuotedColumnName($field, $this->platform)] = $tblAlias . '.' . $transMeta->getQuotedColumnName('content', $this->platform);
         }
     }
     return $result;
 }
 /**
  * Creates a left join list for translations
  * on used query components
  *
  * @todo: make it cleaner
  * @return string
  */
 private function prepareTranslatedComponents()
 {
     $em = $this->getEntityManager();
     $ea = new TranslatableEventAdapter();
     $locale = $this->listener->getListenerLocale();
     $defaultLocale = $this->listener->getDefaultLocale();
     foreach ($this->translatedComponents as $dqlAlias => $comp) {
         $meta = $comp['metadata'];
         $config = $this->listener->getConfiguration($em, $meta->name);
         $transClass = $this->listener->getTranslationClass($ea, $meta->name);
         $transMeta = $em->getClassMetadata($transClass);
         $transTable = $transMeta->getQuotedTableName($this->platform);
         if ($locale !== $defaultLocale) {
             foreach ($config['fields'] as $field) {
                 $compTableName = $meta->getQuotedTableName($this->platform);
                 $compTblAlias = $this->getSQLTableAlias($compTableName, $dqlAlias);
                 $tblAlias = $this->getSQLTableAlias('trans' . $compTblAlias . $field);
                 $sql = ' LEFT JOIN ' . $transTable . ' ' . $tblAlias;
                 $sql .= ' ON ' . $tblAlias . '.' . $transMeta->getQuotedColumnName('locale', $this->platform) . ' = ' . $this->conn->quote($locale);
                 $sql .= ' AND ' . $tblAlias . '.' . $transMeta->getQuotedColumnName('objectClass', $this->platform) . ' = ' . $this->conn->quote($meta->name);
                 $sql .= ' AND ' . $tblAlias . '.' . $transMeta->getQuotedColumnName('field', $this->platform) . ' = ' . $this->conn->quote($field);
                 $identifier = $meta->getSingleIdentifierFieldName();
                 $colName = $meta->getQuotedColumnName($identifier, $this->platform);
                 $sql .= ' AND ' . $tblAlias . '.' . $transMeta->getQuotedColumnName('foreignKey', $this->platform) . ' = ' . $compTblAlias . '.' . $colName;
                 isset($this->components[$dqlAlias]) ? $this->components[$dqlAlias] .= $sql : ($this->components[$dqlAlias] = $sql);
                 if ($this->needsFallback()) {
                     // COALESCE with the original record columns
                     $this->replacements[$compTblAlias . '.' . $meta->getQuotedColumnName($field, $this->platform)] = 'COALESCE(' . $tblAlias . '.' . $transMeta->getQuotedColumnName('content', $this->platform) . ', ' . $compTblAlias . '.' . $meta->getQuotedColumnName($field, $this->platform) . ')';
                 } else {
                     $this->replacements[$compTblAlias . '.' . $meta->getQuotedColumnName($field, $this->platform)] = $tblAlias . '.' . $transMeta->getQuotedColumnName('content', $this->platform);
                 }
             }
         }
     }
 }
Example #10
0
 /**
  * Deletes this entry in the table
  * @return $this
  */
 public function delete()
 {
     reset($this->__fields);
     $pk = key($this->__fields);
     $this->__db->delete($this->getTableName(), array($pk => $this->__get($pk)));
     return $this;
 }
 public function insertRows(PersistentCollection $coll)
 {
     $insertDiff = $coll->getInsertDiff();
     $sql = $this->_getInsertRowSQL($coll);
     foreach ($insertDiff as $element) {
         $this->_conn->executeUpdate($sql, $this->_getInsertRowSQLParameters($coll, $element));
     }
 }
 /**
  * Zapisuje rekord do dziennika.
  * 
  * @todo Użyj QueryBuilder
  * @todo Lokalizacja daty $logRecord['datetime']->format('Y-m-d H:i:s');
  * @param array $logRecord Rekord dziennika
  * @throws RuntimeException Rekord nie został zapisany
  * @throws \Doctrine\DBAL\DBALException Problem z zapisem rekordu
  */
 protected function write(array $logRecord)
 {
     $record = [];
     $record['id'] = null;
     $record['user_id'] = $logRecord['extra']['userid'];
     $record['channel'] = $logRecord['channel'];
     $record['level'] = $logRecord['level'];
     $record['level_name'] = $logRecord['level_name'];
     $record['message'] = $logRecord['formatted'];
     $record['viewed'] = 1;
     $record['extended_message'] = $logRecord['extra']['extended'];
     $record['created'] = $logRecord['datetime']->format('Y-m-d H:i:s');
     $insertResult = $this->connection->insert(self::TABLE_NAME, $record);
     if ($insertResult != 1) {
         throw new RuntimeException('Handling log record failed');
     }
 }
 /**
  * Checks whether the given managed entity exists in the database.
  *
  * @param object $entity
  * @return boolean TRUE if the entity exists in the database, FALSE otherwise.
  */
 public function exists($entity, array $extraConditions = array())
 {
     $criteria = $this->_class->getIdentifierValues($entity);
     if ($extraConditions) {
         $criteria = array_merge($criteria, $extraConditions);
     }
     $sql = 'SELECT 1 FROM ' . $this->_class->getQuotedTableName($this->_platform) . ' ' . $this->_getSQLTableAlias($this->_class->name) . ' WHERE ' . $this->_getSelectConditionSQL($criteria);
     return (bool) $this->_conn->fetchColumn($sql, array_values($criteria));
 }
 /**
  * Loads a collection of entities of a many-to-many association.
  *
  * @param ManyToManyMapping $assoc
  * @param array $criteria
  * @param PersistentCollection $coll The collection to fill.
  */
 public function loadManyToManyCollection($assoc, array $criteria, PersistentCollection $coll)
 {
     $sql = $this->_getSelectManyToManyEntityCollectionSQL($assoc, $criteria);
     $params = array_values($criteria);
     $stmt = $this->_conn->executeQuery($sql, $params);
     while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $coll->hydrateAdd($this->_createEntity($result));
     }
     $stmt->closeCursor();
 }
 /**
  * Creates a left join list for translations
  * on used query components
  *
  * @todo: make it cleaner
  * @return string
  */
 private function prepareTranslatedComponents()
 {
     $q = $this->getQuery();
     $locale = $q->getHint(TranslatableListener::HINT_TRANSLATABLE_LOCALE);
     if (!$locale) {
         // use from listener
         $locale = $this->listener->getListenerLocale();
     }
     $defaultLocale = $this->listener->getDefaultLocale();
     if ($locale === $defaultLocale) {
         // Skip preparation as there's no need to translate anything
         return;
     }
     $em = $this->getEntityManager();
     $ea = new TranslatableEventAdapter();
     $ea->setEntityManager($em);
     $joinStrategy = $q->getHint(TranslatableListener::HINT_INNER_JOIN) ? 'INNER' : 'LEFT';
     foreach ($this->translatedComponents as $dqlAlias => $comp) {
         $meta = $comp['metadata'];
         $config = $this->listener->getConfiguration($em, $meta->name);
         $transClass = $this->listener->getTranslationClass($ea, $meta->name);
         $transMeta = $em->getClassMetadata($transClass);
         $transTable = $transMeta->getQuotedTableName($this->platform);
         foreach ($config['fields'] as $field) {
             $compTableName = $meta->getQuotedTableName($this->platform);
             $compTblAlias = $this->getSQLTableAlias($compTableName, $dqlAlias);
             $tblAlias = $this->getSQLTableAlias('trans' . $compTblAlias . $field);
             $sql = " {$joinStrategy} JOIN " . $transTable . ' ' . $tblAlias;
             $sql .= ' ON ' . $tblAlias . '.' . $transMeta->getQuotedColumnName('locale', $this->platform) . ' = ' . $this->conn->quote($locale);
             $sql .= ' AND ' . $tblAlias . '.' . $transMeta->getQuotedColumnName('field', $this->platform) . ' = ' . $this->conn->quote($field);
             $identifier = $meta->getSingleIdentifierFieldName();
             $idColName = $meta->getQuotedColumnName($identifier, $this->platform);
             if ($ea->usesPersonalTranslation($transClass)) {
                 $sql .= ' AND ' . $tblAlias . '.' . $transMeta->getSingleAssociationJoinColumnName('object') . ' = ' . $compTblAlias . '.' . $idColName;
             } else {
                 $sql .= ' AND ' . $tblAlias . '.' . $transMeta->getQuotedColumnName('objectClass', $this->platform) . ' = ' . $this->conn->quote($meta->name);
                 $sql .= ' AND ' . $tblAlias . '.' . $transMeta->getQuotedColumnName('foreignKey', $this->platform) . ' = ' . $compTblAlias . '.' . $idColName;
             }
             isset($this->components[$dqlAlias]) ? $this->components[$dqlAlias] .= $sql : ($this->components[$dqlAlias] = $sql);
             $originalField = $compTblAlias . '.' . $meta->getQuotedColumnName($field, $this->platform);
             $substituteField = $tblAlias . '.' . $transMeta->getQuotedColumnName('content', $this->platform);
             // If original field is integer - treat translation as integer (for ORDER BY, WHERE, etc)
             $fieldMapping = $meta->getFieldMapping($field);
             if (in_array($fieldMapping["type"], array("integer", "bigint", "tinyint", "int"))) {
                 $substituteField = 'CAST(' . $substituteField . ' AS SIGNED)';
             }
             // Fallback to original if was asked for
             if ($this->needsFallback()) {
                 $substituteField = 'COALESCE(' . $substituteField . ', ' . $originalField . ')';
             }
             $this->replacements[$originalField] = $substituteField;
         }
     }
 }
Example #16
0
 /**
  * Loads a collection of entities in a one-to-many association.
  *
  * @param OneToManyMapping $assoc
  * @param array $criteria The criteria by which to select the entities.
  * @param PersistentCollection The collection to load/fill.
  */
 public function loadOneToManyCollection(OneToManyMapping $assoc, $sourceEntity, PersistentCollection $coll)
 {
     $criteria = array();
     $owningAssoc = $this->_class->associationMappings[$assoc->mappedBy];
     $sourceClass = $this->_em->getClassMetadata($assoc->sourceEntityName);
     foreach ($owningAssoc->targetToSourceKeyColumns as $sourceKeyColumn => $targetKeyColumn) {
         $criteria[$targetKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity);
     }
     $sql = $this->_getSelectEntitiesSQL($criteria, $assoc);
     $params = array_values($criteria);
     $stmt = $this->_conn->executeQuery($sql, $params);
     while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $coll->hydrateAdd($this->_createEntity($result));
     }
     $stmt->closeCursor();
 }
 /**
  * Loads an entity by a list of field criteria.
  *
  * @param array $criteria The criteria by which to load the entity.
  * @param object $entity The entity to load the data into. If not specified,
  *                       a new entity is created.
  */
 public function load(array $criteria, $entity = null)
 {
     $stmt = $this->_conn->prepare($this->_getSelectSingleEntitySql($criteria));
     $stmt->execute(array_values($criteria));
     $data = array();
     foreach ($stmt->fetch(\PDO::FETCH_ASSOC) as $column => $value) {
         $fieldName = $this->_class->fieldNames[$column];
         $data[$fieldName] = Type::getType($this->_class->getTypeOfField($fieldName))->convertToPHPValue($value);
     }
     $stmt->closeCursor();
     if ($entity === null) {
         $entity = $this->_em->getUnitOfWork()->createEntity($this->_entityName, $data);
     } else {
         foreach ($data as $field => $value) {
             $this->_class->reflFields[$field]->setValue($entity, $value);
         }
         $id = array();
         if ($this->_class->isIdentifierComposite) {
             foreach ($this->_class->identifier as $fieldName) {
                 $id[] = $data[$fieldName];
             }
         } else {
             $id = array($data[$this->_class->getSingleIdentifierFieldName()]);
         }
         $this->_em->getUnitOfWork()->registerManaged($entity, $id, $data);
     }
     if (!$this->_em->getConfiguration()->getAllowPartialObjects()) {
         foreach ($this->_class->associationMappings as $field => $assoc) {
             if ($assoc->isOneToOne()) {
                 if ($assoc->isLazilyFetched()) {
                     // Inject proxy
                     $proxy = $this->_em->getProxyGenerator()->getAssociationProxy($entity, $assoc);
                     $this->_class->reflFields[$field]->setValue($entity, $proxy);
                 } else {
                     //TODO: Eager fetch?
                 }
             } else {
                 // Inject collection
                 $this->_class->reflFields[$field]->setValue($entity, new PersistentCollection($this->_em, $this->_em->getClassMetadata($assoc->targetEntityName)));
             }
         }
     }
     return $entity;
 }
Example #18
0
 /**
  * Shrani array sprememb entitet v bazo
  *
  * @param array $changes
  */
 protected function saveChanges($changes)
 {
     $sql = "INSERT INTO {$this->tableName} (razred, objectId, upor, datum, tip, data)\n                VALUES (?, ?, ?, ?, ?, ?)";
     $stmt = $this->conn->prepare($sql);
     $date = date_create("now")->format($this->platform->getDateTimeFormatString());
     $user = $this->identity ? $this->identity->getId() : null;
     foreach ($changes as $objectId => $change) {
         $class = get_class($change['entity']);
         $type = $change['type'];
         $data = serialize($change['data']);
         $stmt->bindValue(1, $class, \PDO::PARAM_STR);
         $stmt->bindValue(2, $objectId, \PDO::PARAM_STR);
         $stmt->bindValue(3, $user, \PDO::PARAM_STR);
         $stmt->bindValue(4, $date, \PDO::PARAM_STR);
         $stmt->bindValue(5, $type, \PDO::PARAM_STR);
         $stmt->bindValue(6, $data, \PDO::PARAM_STR);
         $stmt->execute();
     }
 }
Example #19
0
 public function delete($id)
 {
     return $this->db->delete('zadania', array('id' => $id));
 }
Example #20
0
 /**
  * Walks down a StringPrimary that represents an AST node, thereby generating the appropriate SQL.
  *
  * @param mixed
  * @return string The SQL.
  */
 public function walkStringPrimary($stringPrimary)
 {
     return is_string($stringPrimary) ? $this->_conn->quote($stringPrimary) : $stringPrimary->dispatch($this);
 }
Example #21
0
 /**
  * @Given /^data was loaded independantley of Phabric$/
  */
 public function dataWasLoadedIndependantleyOfPhabric()
 {
     $data = array('name' => 'PBC11', 'datetime' => '2011-10-28 09:00:00', 'venue' => 'Barcellona', 'description' => 'HOT conf');
     $db = self::$db->insert('event', $data);
 }
 /**
  * Check whether the current transaction is marked for rollback only.
  *
  * @return boolean
  * @throws Doctrine\DBAL\ConnectionException If no transaction is active.
  */
 public function isRollbackOnly()
 {
     return $this->_conn->isRollbackOnly();
 }
 /**
  * Setup the metadata driver if necessary options are set. Otherwise Doctrine defaults are used (AnnotationReader).
  *
  * @param array $options
  * @param Doctrine\ORM\Configuration $config
  * @param Doctrine\Common\Cache\AbstractCache $cache
  * @param Doctrine\DBAL\Connection $conn
  */
 protected function _setupMetadataDriver($options, $config, $cache, $conn)
 {
     $driver = false;
     if (isset($options['metadata'])) {
         if (isset($options['metadata']['driver'])) {
             $driverName = $options['metadata']['driver'];
             switch (strtolower($driverName)) {
                 case 'annotation':
                     $driverName = 'Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver';
                     break;
                 case 'yaml':
                     $driverName = 'Doctrine\\ORM\\Mapping\\Driver\\YamlDriver';
                     break;
                 case 'xml':
                     $driverName = 'Doctrine\\ORM\\Mapping\\Driver\\XmlDriver';
                     break;
                 case 'php':
                     $driverName = 'Doctrine\\ORM\\Mapping\\Driver\\PhpDriver';
                     break;
                 case 'database':
                     $driverName = 'Doctrine\\ORM\\Mapping\\Driver\\DatabaseDriver';
                     break;
             }
             if (!class_exists($driverName)) {
                 throw new ZendX_Doctrine2_Exception("MetadataDriver class '" . $driverName . "' does not exist");
             }
             if (in_array('Doctrine\\ORM\\Mapping\\Driver\\AbstractFileDriver', class_parents($driverName))) {
                 if (!isset($options['metadata']['paths'])) {
                     throw new ZendX_Doctrine2_Exception("Metadata Driver is file based, but no config file paths were given.");
                 }
                 if (!isset($options['metadata']['mode'])) {
                     $options['metadata']['mode'] = \Doctrine\ORM\Mapping\Driver\AbstractFileDriver::FILE_PER_CLASS;
                 }
                 $driver = new $driverName($options['metadata']['paths'], $options['metadata']['mode']);
             } elseif ($driverName == 'Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver') {
                 $reader = new \Doctrine\Common\Annotations\AnnotationReader($cache);
                 $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
                 $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
                 if (isset($options['metadata']['classDirectory'])) {
                     $driver->addPaths(array($options['metadata']['classDirectory']));
                 } else {
                     throw new ZendX_Doctrine2_Exception("Doctrine Annotation Driver requires to set a class directory for the entities.");
                 }
                 //$driverImpl = $config->newDefaultAnnotationDriver("var/www/zfbench/application/models"));
                 //$config->setMetadataDriverImpl($driverImpl);
             } elseif ($driverName == 'Doctrine\\ORM\\Mapping\\Driver\\DatabaseDriver') {
                 $schemaManager = $conn->getSchemaManager();
                 $driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($schemaManager);
             }
             if (!$driver instanceof \Doctrine\ORM\Mapping\Driver\Driver) {
                 throw new ZendX_Doctrine2_Exception("No metadata driver could be loaded.");
             }
             $config->setMetadataDriverImpl($driver);
         }
     }
 }
 /**
  * @return Doctrine\DBAL\Schema\AbstractSchemaManager
  */
 private function getSchemaManager()
 {
     return $this->connection->getSchemaManager();
 }
 /**
  * Reads one employee record from database.
  *
  * @param  Doctrine\DBAL\Connection $_db An Doctrine DBAL Connection instance
  * @param  integer $_id The ID of the employee resource
  * @return array The result from a database query
  *
  * @todo Check parameters from REQUEST
  * @todo Error handling
  */
 protected function _readOne($_id, $_db)
 {
     $employee = $_db->createQueryBuilder()->select('e.*', 'd.name as "department"')->from('company_employees', 'e')->leftJoin('e', 'company_departments', 'd', 'e.department_id = d.id')->andWhere('e.id = :id')->setParameters(array('id' => $_id))->execute();
     return array('success' => true, 'data' => $employee->fetchAll(\PDO::FETCH_ASSOC));
 }