Jump to content

bogdaniel

Members
  • Posts

    65
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

bogdaniel's Achievements

Member

Member (2/5)

0

Reputation

  1. haha i'm soo happy can't wait to get home and check it out
  2. when i get home i'll test the code no worries for the twig i'll rewrite the code to be with what i'm using i already noticed a difference in the mysql query that from what i can think of might make the difference, i wasn't sure on the sql part if it's done right and complete.. i'm sure i've missed out something about the data output. let know in 3 hours what i've done. cheers for answering to my post
  3. yes it retrieves the data but i didn't manage echoing in the table. if you check the html output you would see there that it created a third Catalog-View for moderator instead of putting 1 on the column moderator. for the number 2 public function ListPermissionNames() { $this->database->query("SELECT t2.RoleName, t2.RoleName, t3.PermissionName, t3.PermissionName, t1.PermissionId FROM tbl_user_role_perm AS t1 INNER JOIN tbl_user_roles AS t2 ON t1.RoleId = t2.RoleId INNER JOIN tbl_user_permissions AS t3 ON t1.PermissionId = t3.PermissionId"); $this->database->execute(); $this->database->setFetchMode(PDO::FETCH_ASSOC); return $this->database->resultSet(PDO::FETCH_GROUP, PDO::FETCH_ASSOC); 3 & 4 i posted a picture with this post to show exact the example that i wanna achieve and i don't know how to do it. i'm generating td's and everything but instead of putting 1 for administrator and 1 for moderator it creates a new line bellow ( see HTML OUTPUT).
  4. Hello I have an array with data from `mysql` that I would like to output it in a table using twig. The image is an example of want i want to achieve but without any luck. `print_r` of the array data Array ( [Administrator] => Array ( [0] => Array ( [RoleName] => Administrator [PermissionName] => Catalog-View [PermissionId] => 1 ) [1] => Array ( [RoleName] => Administrator [PermissionName] => Catalog-Edit [PermissionId] => 2 ) [2] => Array ( [RoleName] => Administrator [PermissionName] => Catalog-Delete [PermissionId] => 3 ) ) [Moderator] => Array ( [0] => Array ( [RoleName] => Moderator [PermissionName] => Catalog-View [PermissionId] => 1 ) ) ) The `HTML` code: <table> <tr> <thead> <th>Controller - Action</th> {% for permission in permissions %} {% for item in permission %} <th>{{item.RoleName}}</th> {% endfor %} {% endfor %} </thead> </tr> {% for permission in permissions %} {% for item in permission %} <tr> <td>{{item.PermissionName}}</td> <td>{{item.PermissionId}}</td> </tr> {% endfor %} {% endfor %} </table> OUTPUT: <table> <tbody> <tr></tr> </tbody> <thead> <tr> <th>Controller - Action</th> <th>Administrator</th> <th>Administrator</th> <th>Administrator</th> <th>Moderator</th> </tr> </thead> <tbody> <tr> <td>Catalog-View</td> <td>1</td> </tr> <tr> <td>Catalog-Edit</td> <td>2</td> </tr> <tr> <td>Catalog-Delete</td> <td>3</td> </tr> <tr> <td>Catalog-View</td> <td>1</td> </tr> </tbody> </table> Later Edit MySQL Query: SELECT t3.PermissionName, t1.PermissionId, t2.RoleName FROM tbl_user_role_perm AS t1 INNER JOIN tbl_user_roles AS t2 ON t1.RoleId = t2.RoleId INNER JOIN tbl_user_permissions AS t3 ON t1.PermissionId = t3.PermissionId MySQL Dump: -- Dumping structure for table tbl_user_permissions CREATE TABLE IF NOT EXISTS `tbl_user_permissions` ( `PermissionId` int(11) NOT NULL AUTO_INCREMENT, `PermissionName` varchar(50) NOT NULL, `PermissionDescription` varchar(100) NOT NULL, PRIMARY KEY (`PermissionId`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; -- Dumping data for table tbl_user_permissions: ~2 rows (approximately) DELETE FROM `tbl_user_permissions`; /*!40000 ALTER TABLE `tbl_user_permissions` DISABLE KEYS */; INSERT INTO `tbl_user_permissions` (`PermissionId`, `PermissionName`, `PermissionDescription`) VALUES (1, 'Catalog->View', 'View Catalog Method'), (2, 'Catalog->Edit', 'Edit Catalog Method'), (3, 'Catalog->Delete', 'Delete Catalog Method'); /*!40000 ALTER TABLE `tbl_user_permissions` ENABLE KEYS */; -- Dumping structure for table tbl_user_role CREATE TABLE IF NOT EXISTS `tbl_user_role` ( `UserRoleId` int(10) NOT NULL AUTO_INCREMENT, `UserId` int(10) NOT NULL, `RoleId` int(10) unsigned NOT NULL, PRIMARY KEY (`UserRoleId`), KEY `FK_tbl_user_role_tbl_user_roles` (`RoleId`), KEY `UserId` (`UserId`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; -- Dumping data for table tbl_user_role: ~2 rows (approximately) DELETE FROM `tbl_user_role`; /*!40000 ALTER TABLE `tbl_user_role` DISABLE KEYS */; INSERT INTO `tbl_user_role` (`UserRoleId`, `UserId`, `RoleId`) VALUES (1, 13, 22), (2, 14, 22); /*!40000 ALTER TABLE `tbl_user_role` ENABLE KEYS */; -- Dumping structure for table tbl_user_roles CREATE TABLE IF NOT EXISTS `tbl_user_roles` ( `RoleId` int(10) unsigned NOT NULL AUTO_INCREMENT, `RoleName` varchar(50) NOT NULL, `CreatedDate` datetime NOT NULL, `ModifiedDate` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`RoleId`) ) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8; -- Dumping data for table tbl_user_roles: ~7 rows (approximately) DELETE FROM `tbl_user_roles`; /*!40000 ALTER TABLE `tbl_user_roles` DISABLE KEYS */; INSERT INTO `tbl_user_roles` (`RoleId`, `RoleName`, `CreatedDate`, `ModifiedDate`) VALUES (22, 'Administrator', '2014-10-28 09:53:08', NULL), (23, 'Moderator', '2014-10-28 09:53:13', NULL), (24, 'Admin', '2014-10-28 12:22:05', '2014-10-28 12:22:06'), (25, 'User', '2014-10-29 15:10:36', '2014-10-29 15:10:37'), (26, 'SuperUser', '2014-10-29 15:10:45', '2014-10-29 15:10:46'), (27, 'Accountant', '2014-10-29 15:10:53', '2014-10-29 15:10:54'), (28, 'God', '2014-10-29 15:11:02', '2014-10-29 15:11:02'); /*!40000 ALTER TABLE `tbl_user_roles` ENABLE KEYS */; -- Dumping structure for table tbl_user_role_perm CREATE TABLE IF NOT EXISTS `tbl_user_role_perm` ( `RoleId` int(10) unsigned NOT NULL, `PermissionId` int(10) unsigned NOT NULL, KEY `RoleId` (`RoleId`), KEY `PermissionId` (`PermissionId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- Dumping data for table tbl_user_role_perm: ~3 rows (approximately) DELETE FROM `tbl_user_role_perm`; /*!40000 ALTER TABLE `tbl_user_role_perm` DISABLE KEYS */; INSERT INTO `tbl_user_role_perm` (`RoleId`, `PermissionId`) VALUES (22, 2), (22, 1), (23, 1), (22, 3); /*!40000 ALTER TABLE `tbl_user_role_perm` ENABLE KEYS */; /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; Can you help me to make the coding required so that the correct column have the correct permissions? thank you in advance.
  5. Pull the entire menu in one query, using LEFT JOINs. It will improve performance significantly. Also, consider revising the schema so "links" and "categories" are both stored in the same table of "menu_elements" - a self-referencing table with a "type" column defining what type of menu item it is. i'll do that :-) what about the view part any sugestions.. ?
  6. recently i started working with TinyMVC, wrote a simple menu model and i have few questions for those who are using it .. or used before. 1. For the following code should i keep it as Model or as a Plugin? 2. How should i implement it in the view and use it on every page that is required without breaking the ideea of mvc and without rewriting again and again for each controller? 3. Any improvements to the code? 4. Need the mysql tables ? <?php class Menu_Model extends TinyMVC_Model { public function __construct() { parent::__construct(); } public function listMenu() { return $this->db->query_all("SELECT * FROM menu_links WHERE is_deleted = 0 ORDER BY position"); } public function listCategorys($menuLinkId) { return $this->db->query_all("SELECT * FROM menu_subcategorys WHERE menuLinkId = ? AND is_deleted = 0 ORDER BY position", array($menuLinkId)); } public function buildMenu() { $this->listMenu = $this->listMenu(); foreach($this->listMenu as $this->listMenuKey => $this->listMenuValue) { $this->listCategorys = $this->listCategorys($this->listMenuValue['menuLinkId']); if(!empty($this->listCategorys)) $this->listMenu[$this->listMenuKey]['child'] = $this->listCategorys; } return $this->listMenu; } }
  7. on the xml part i didn't had to much luck on building a menu(i`m new to xml) prob i`ll go for a mysql :-)
  8. hello guys.. i have a strange question... when you work on a website that has a huge menu(per country for example like a travel agency website) and needs to have the option to add delete items from the menu and submenu how do you store it ? xml .. mysql? any sugestions tips..hints..? Thank you very much for you help.
  9. i don't have any clue how to do that but you need javascript.
  10. i`m not sure if you talk only stupid things but this you could achieve creating an array with the user agent of the bots(i think you can find on google about them) but for someone smart and with firefox could enter on your website by changing the user agent. click check this out for more information's.
  11. hello i`m having a small question actually a problem for me because i`m not sure on what..should i use. when you build a user system and after you check the credentials for the user you create a session ok. but what should i use session_register or $_SESSION?
  12. thank you all for your reply. from my vision since it will have a shop i don't think flash will be a good practice. in the end i don't know what i will do because of the client. Anyway thank you all for your help
  13. Hello i've just started to build a website for my boss that will have an online shop a photo gallery a presentation of the company(it's a small one i don't know what he wants to write) a contact form, projects that have been done by them. and this means it will require a lot of php and mysql in it. on the design part i was thinking on going on flash animations but because of the php and other things that will need to be implemented.. i'm not sure what to do the website is about decorating interior designs. My question is should i go for a static design or for a flash implementation and if i got for flash should be entire website or do some hard coded stuff and make a part of it flash and other parts be pure php css.... i need an advice.. maybe ideas about the design the guy showed me that he would want something like: http://www.innova.ro http://www.roma.ro/ http://www.kartell.it/
  14. yes but ... i wanted to be sure ... if the cron job is the good choice or no
  15. i apologize what i wanted to ask was: In game development the resource system you know wood stone stuff like that you get let's say 3200 wood per hour or 6200 if you are a higher lvl on the wood cutter. How should i make this update? when the user logins? page refresh... this is what i wanted to know i've read on a website that most of the games use cron jobs to update the resources gained per hour ..
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.