Jump to content

Garethp

Members
  • Posts

    1,026
  • Joined

  • Last visited

Everything posted by Garethp

  1. Hi there I'm moving on from ZF1 to ZF2 in my latest project, and I'm not sure if I'm doing this right. I've gone through the Skeleton Application and read through the \Zend\Db reference, but I'm not sure if I'm missing something, because the way the ZF2 docs handles Row objects seems a bit backwards. I mean, in ZF1, you just extended an abstract class and you had your functionality right there. The data was stored in _data, and the toArray() function and setValues() and setFromArray() worked without me having to tell the model what columns it was setting. But I can't seem to find an abstract class for Row models in ZF2. Having to manually define the columns seems a bit counter-intuitive, so I'm wondering, am I doing this right is is there infact a Zend\Db\AbstractRow model that I'm missing? Thanks, Gareth
  2. Personally (though trq might know better), I'd suggest downloading and installing http://www.centos.org/ and then installing Apache, Mysql and PHP. It's not that hard, a simple sudo yum install httpd mysql-server php php-mysql Should install pretty much everything you need in one go
  3. Maybe I'm just too used to high-level languages, or maybe I don't know enough languages (For example, I don't know C. Need to get around to fixing that), but I tried my hand at learning Objective C once, and it just seemed like an over-convoluted language that went out of it's way to be different, not for the sake of improvement, but just for the sake of being different. But then again, maybe I'm inexperienced and maybe I'm just biased against Apple...
  4. Thanks for setting me straight guys, it's this kind of knowledge that I didn't know about the job market that's useful @.jsoh: What exactly do you mean by entry level? I mean, I've been doing "Mid" level jobs for a couple years now, and I'm not sure what an Entry level wage is? But thanks for your post. I've had my fill of internal politics, and with your help I can now maybe avoid a couple more companies that are too rife with them @KevinM1: I um... actually didn't know that to be honest. I just thought Senior was a designation of skill level and pay grade. But thanks for your blunt-ness, it's really helpful
  5. In my opinion any decent machine from the last four years should be able to handle that, but I'm not sure to be honest. I've never used a Windows machine for any more than one person (me). I'd suggest if you're looking for something efficient, turn the machine into a LAMP stack with CentOS. From what I know, there'll be more resources dedicated to serving webpages that way than if you run it on Windows...
  6. Hm, what's happened in my previous workplace that I rather liked was that developers worked on local machines, then they'd commit their changes to version control (SVN, Git, doesn't matter) and it was automatically pushed to a staging server that was local, and once it was tested it was pushed to a live server manually. What I would have liked was if there was a staging branch to the repository that got automatically pushed to staging, and a release branch that was automatically pushed to live. Though maybe not automatically, since you should always take more care pushing to live...
  7. I see, that definitely changes how I'm going to approach this, thanks Hm, so basically having 3-5 years on my resume isn't enough to go for a Senior Developer position? In most companies I have to work my way up from Mid to Senior? Alright, I'm going to try to look for some PHP projects that could use an extra hand or two
  8. Sorry for the late reply. I would have replied to .josh, but I didn't really have anything more than "I agree and you opened my eyes". I guess because I'm only 21 and trying to shoot for Senior positions I feel like I have something to prove. Not knowing how to write a Cover Letter (and thereby not really bothering with them, just sending in my Resume) and not knowing if I'm quite good enough doesn't help. I would go for the companies that I want to work for, and write Cover Letters for them, but in my few years in the job market I've noticed that most companies I work with take years to really implement bigger changes, while I want to be learning something completely new every few months. I've been contracting for the last year and it's rather helped me satisfy my urges to challenge myself every couple of months. I know if sounds like an excuse, since I could learn the things even if the companies I work for don't implement them, but it doesn't feel like I learn quite as much or quite as well when I'm not just thrown into it and forced to learn how to do something knew, you know? Yeah, I'll have to jump onto the PHPFreaks IRC some time. To be honest when I joined the internet (All of 8 years ago), IRC was kind of popular, but I always felt like it was dying out. If IRC is still kicking happily, I'll have to reassess that and spend some time chatting away on it. I really should join some open source projects, but I'm not quite sure where to start. I mean, the only skills I feel confident enough to use to contribute is PHP/MySQL and JS/HTML/CSS, and all of the projects I see in those areas are all already so full of more talented, more skilled people than me that I just don't know what to do. How does one find a project that hasn't already got enough people?
  9. You're from Sydney, so maybe you can suggest other ways of finding contracts/jobs? The reason I want to do something to put on a resume site is because all of my work so far has been private. Backend work that I can't link and can't show the source code, which sucks because personally I believe that my code style says a lot about me, and I want to have something to show people, you know? So far I've only gotten jobs through seek.com.au, but for some reason I get the feeling that seek only has a partial view of the job market. For example, why is it that 90% of the time I apply for a job I go through recruiters? How do I find jobs in Sydney that don't go through recruiters? Are there more jobs sites? How do I get my name out there? Sorry for all the questions, but you raised a good point about it not helping my cause. It won't stop me from doing it though, because I want to be able to showcase my skills. And after your point well raised, I'm not quite sure what the best way is to get better jobs. It's not like I'm doing poorly in the job market, I just have this well of ambition that demands that I rise higher, but I'm not sure how to do that...
  10. So, I was considering building a website to accompany my resume, and hopefully start off a freelancing career, and I was thinking of building some examples on GitHub that might be useful for getting me jobs. Being a PHP programmer, all of my jobs so far have been private, and I can't just link to the work I've done. So I was curious what projects would be good, from a hiring stance, to showcase my skills to potential employers. I'm not sure if this would be the same as the list of projects to tackle if you get bored, but if so just let me know. So tell me PHPFreaks, what would be some good ideas to develop code examples for employment prospectives? PS: Forgive me if I'm posting in the wrong place, or if my posting style is wrong for this forum, I haven't been around these parts in a while
  11. I was just wondering if there was a decent site for it? I haven't really been in the freelancing scene before
  12. Hey guys, I haven't been active on this forum for a few years, but every time I need some advice or ideas PHP related I always seem to come back here for them, so I was wondering if anyone knew some good freelance sites for USA. I'm usually in Australia, but I'm over here visiting friends for the next month, and I find myself with an excess of time on my hands, my friends having jobs and such. Any advice or links would be greatly appreciated, thanks
  13. Edit: Sorry, I don't know how to edit the main post, but I forgot my MySQL version. It's 5.1.61
  14. So, one of the sites I'm maintaining has a few very bad queries, and I'm just trying to track down what's the worst. Anyway, here's one of the queries that I could really use some help with, please. I've tried adding a key on hit_url_item, and hit_url_content, but no luck in making it use indexes. What can I do to make this query more efficient? SELECT hit_name, COUNT( hit_id ) AS hits, CONCAT_WS( '/', `hit_url_content` , `hit_url_item` ) AS hit_url FROM sc_hits WHERE hit_url_content = 'articles/products/furniture' GROUP BY hit_url_item ORDER BY hits DESC LIMIT 5 Explained id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE sc_hits index hit_url_content hit_url_item 767 NULL 1994330 Using where; Using temporary; Using filesort SHOW CREATE TABLE CREATE TABLE `sc_hits` ( `hit_id` int(11) NOT NULL AUTO_INCREMENT, `hit_url_content` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `hit_url_item` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `hit_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL, `hit_date` datetime NOT NULL, PRIMARY KEY (`hit_id`), KEY `hit_url_content` (`hit_url_content`), KEY `hit_url_item` (`hit_url_item`), KEY `hit_date` (`hit_date`) ) ENGINE=MyISAM AUTO_INCREMENT=14838361 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
  15. So, I've got this project built in Zend Framework, and this page particularly is slow, due to this query # Time: 120720 16:57:59 # Query_time: 10.803516 Lock_time: 0.000127 Rows_sent: 10 Rows_examined: 21057621 SET timestamp=1342767479; SELECT `projects_projects`.*, COUNT(*) AS `Hits` FROM `projects_projects` LEFT JOIN `projects_hits` ON projects_hits.ProjectID=projects_projects.ID LEFT JOIN `projects_in_subcategories` ON projects_in_subcategories.ProjectID=projects_projects.ID LEFT JOIN `projects_subcategories` ON projects_subcategories.ID=projects_in_subcategories.SubCategoryID LEFT JOIN `projects_categories` ON projects_categories.ID=projects_subcategories.CategoryID WHERE (projects_projects.Published=1) AND (projects_categories.ID='10') GROUP BY `projects_projects`.`ID` ORDER BY `Created` DESC LIMIT 10 OFFSET 80; As detected by my Slow Query Log Basically what I've got is a table of projects, a table of project categories, and a table of subcategories, and a joining table that ties projects and subcategories together, as well as get how many hits said projects have And this page has to show 10 projects within a certain parent category. This particular query is taking 10 seconds, as you can see, and Zend is also using another query to create the paginator count, which takes another 10 seconds (query at the bottom). So what can I do to speed this up? Paginator Query # Time: 120720 16:57:48 # User@Host: habitususer5[habitususer5] @ [113.192.3.227] # Query_time: 10.088245 Lock_time: 0.000335 Rows_sent: 1 Rows_examined: 21057435 SET timestamp=1342767468; SELECT COUNT(DISTINCT `projects_projects`.`ID`) AS `zend_paginator_row_count` FROM `projects_projects` LEFT JOIN `projects_hits` ON projects_hits.ProjectID=projects_projects.ID LEFT JOIN `projects_in_subcategories` ON projects_in_subcategories.ProjectID=projects_projects.ID LEFT JOIN `projects_subcategories` ON projects_subcategories.ID=projects_in_subcategories.SubCategoryID LEFT JOIN `projects_categories` ON projects_categories.ID=projects_subcategories.CategoryID WHERE (projects_projects.Published=1) AND (projects_categories.ID='10');
  16. Look at PFMaBiSmAd's code. Now back to your code, now back to his. Is your code his? No, but if could be if you put those three variables into an array BEFORE putting them through a function that filters an array
  17. Under a "forms" folder, create a model that extends Zend_Form, override the init function for adding elements class Something_Form_Login extends Zend_Form { public function init() { $Username = new Zend_Form_Element_Text('Username'); $Username->setLabel('Username'); $Password = new Zend_Form_Element_Password('Password'); $Password->setLabel('Password'); $Submit = new Zend_Form_Element_Submit('Submit'); $this->addElements(array($Username, $Password, $Submit)); } }
  18. Okay, so I have a plugin that's meant to check whether the user is allowed to view a page or not, and should redirect them if they aren't. Thing is, whenever I try to use new Framework_Model_Acl or try to call a class from any module from within the plugin, I just get a fatal class not found error. Fatal error: Class 'Framework_Model_Acl' not found in [removed]/application/plugins/PermissionCheck.php on line 10 If I try to call the same class from a controller or bootstrap it works fine. So what's going on?
  19. Okay guys, so I'm going to start a large program for work soon, which we expect to have to expand the servers we're running it on quite a bit. So the Senior Technician that's working on the server side wants to put the view on another server from the controllers and models, so that if need be we can scale the one or the other. So one set of servers would just be serving the HTML and another set of servers would be handling the business logic. Does anyone know of an efficient and not overly complicated way to do this?
  20. Hey all, I'm fairly new to the more advanced functions of Zend such as plugins and contexts, and I'm a bit stuck, is there any chance you guys could help me out? Basically I'm creating a plugin that will look for json as a Param, and if it's in there, and the current view has another file with json as a suffix (such as view.json.phtml), to render that view instead. Here's the code <?php class Plugin_LayoutManager extends Zend_Controller_Plugin_Abstract { public function postDispatch() { $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap'); $layout = Zend_Layout::getMvcInstance(); $view = $bootstrap->getResource('view'); $controller = $bootstrap->getResource('controller'); $controllerParam = $this->_request->getParam('controller'); $action = $this->_request->getParam('action'); $context = Zend_Controller_Action_HelperBroker::getStaticHelper('contextSwitch'); $context->initContext('json'); if(($json = $this->_request->getParam('json'))) { if($this->_scriptExists($controllerParam . "/" . $action. ".json")) { $context = Zend_Controller_Action_HelperBroker::getExistingHelper('contextSwitch'); $context->initContext('json'); } } } protected function _fileExists($file) { $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap'); $layout = Zend_Layout::getMvcInstance(); $view = $bootstrap->getResource('view'); $paths = $view->getScriptPaths(); foreach ($paths as $path) { if (file_exists($path . $file . ".phtml")) { return true; } } return false; } protected function _scriptExists($file) { return $this->_fileExists($file); } } I've tried putting that in preDispatch, I've tried using $view->render(), I've tried getting the context a number of different ways. I'm at my wits end here. Any help would be appreciated. Thank you
  21. Thanks, I'll look at using a stored procedure. The reason why I'm using a start time and an end time is that it will eventually be used for a table that will hold a varying percentage for values on another table (so this will have a column percentage, which will be calculated against the column on the other table), and it needs to be applied during a certain time period (so past transactions will only use the percentage that was set at the time of it's transaction), and this is the easiest way for me to do it. I ruled out putting the percentage on the transaction row because I don't want to disturb that program at all (it was made by my predecessor, so it's a bit fragile). Thanks for your reply though!
  22. Okay, so I have a table test that is ---------------------------------- | ID | Begin | End | ---------------------------------- | int(10) | int(10) | int(10) | ---------------------------------- With ID being an auto-increment. What I want to do is create a trigger to automatically set Begin to the current timestamp when inserted, and to set End to the timestamp at which the newest row is entered (so that only the most current row will have an End of 0, the others will have the timestamp that they were no longer the current row). Triggers at teh bottom. My problem being that I'm getting the error "Can't update table 'test' in stored function/trigger because it is already used by statement which invoked this stored function/trigger." Presumably because it doesn't want me to update test when the trigger is called from test. The problem is that it's very important to the final production of this to make sure that the integrity of the data is 100%, hence my putting them in triggers instead of doing it via PHP. Does anyone have any suggestions on how I can do this? Before Insert CREATE TRIGGER set_begin BEFORE INSERT ON test FOR EACH ROW BEGIN SET NEW.Begin = NOW(); SET NEW.End = 0; END; | After Insert CREATE TRIGGER update_end AFTER INSERT ON test FOR EACH ROW BEGIN UPDATE test SET End = NOW() WHERE End = 0; END; |
  23. Yes, I have. My module name is framework, in the Module bootstrap I've set it's namespace to be Framework (capital). The controller is controllers/IndexController.php Framework_IndexController extends Zend_Controller_Action, the view is views/scripts/index/index.phtml
  24. Hey guys, I'm having a little problem. I have three tables. sites, devices, and device_status. Basically, device_status holds multiple rows per device, of when the device last pinged on of our servers, and each site can have multiple sites. So what I'm trying to do is find when a site was first created, but finding when it's devices first pinged us, and get all sites set up since October. What I tried was SELECT sites.*, MIN(device_status) as firstcontact FROM sites LEFT JOIN devices ON devices.siteid=sites.id LEFT JOIN device_status on device_status.deviceid=devices.id GROUP BY sites.id HAVING firstcontact > UNIX_TIMESTAMP('2010-08-01') ORDER BY firstcontact DESC But it shows no sites, and only two sites when I change it to January of 2010. My guess is that this is a result of the GROUP BY sites.id, and I was thinking that if I could somehow group by devices and sites it might show the correct results. How would I do this?
  25. Ah, thanks. I ended up just passing the object in through a custom function, and just adding the attribute straight to the object
×
×
  • 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.