Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. You can use them on any function that doesn't return a value. It's not exclusive for setters.
  2. I see xyph already helped you, I'll add the below code if anyone ever comes across this topic. I had a play with it yesterday and tried to mimic SQL like functionality in PHP for CSV files. Please use SQL for any large CSV file. class CSVFileObject { private $_file; private $_skipFirst; public function __construct($csvFile, $delimiter = ',', $enclosure = '"', $escape = '\\', $skipFirst = false) { $this->_file = new SplFileObject($csvFile); $this->_file->setFlags(SplFileObject::READ_CSV); $this->_file->setCsvControl($delimiter, $enclosure, $escape); $this->_skipFirst = $skipFirst; } public function rewind() { $this->_file->rewind(); } public function readLine($line = null) { if ($line !== null) { $this->_file->seek($line); } if (!$this->_file->valid()) { return false; } if ($this->_file->key() === 0 && $this->_skipFirst) { $this->_file->next(); if (!$this->_file->valid()) { return false; } } $line = $this->_file->current(); $this->_file->next(); if (!is_array($line)) { return false; } return $line; } } interface Matcher { public function match($o); } class CSVComplexSearch { private $_csv; public function __construct(CSVFileObject $csv) { $this->_csv = $csv; } public function findWhereMatches(Matcher $matcher) { $result = new ArrayObject; while (($line = $this->_csv->readLine()) !== false) { if ($matcher->match($line)) { $result->append($line); } } return $result; } } class MyMatcher implements Matcher { private $_line; public function match($o) { $this->_line = $o; return ( $this->_whereFirstNameIs('foo') && $this->_whereLastNameIs('bar') ); } private function _whereFirstNameIs($str) { return $this->_line[0] === $str; } private function _whereLastNameIs($str) { return $this->_line[1] === $str; } } You use it like this: $search = new CSVComplexSearch(new CSVFileObject('users.csv')); var_dump($search->findWhereMatches(new MyMatcher));
  3. $sql = "SELECT * FROM users WHERE username = '{$email}' AND password = '{$password}'"; $result = mysql_query($sql) or exit("ERROR: " . mysql_error() . "<br>IN QUERY: " . $sql); Gives you a description of what's wrong with your query. It's advisable not to use or exit() in production environments.
  4. You can just do it in MySQL: SELECT floor( (to_days(now()) - to_days(birthday)) / 365.25 ); Create a user-defined function age() in MySQL and you can do this: SELECT age(birthday) AS user_age;
  5. I would look into Zend or Kohana as both support DB abstraction and provice ACL management. Finding a PayPal component for Zend (or Kohana) won't be hard either but as it's not part of the official Zend distro I would suggest writing your own or at least ask sufficient advise concerning the subject as this is your main source of income and should be near error-free. The project looks easy enough IMO with these components in place.
  6. You should allow Apache to access the Thrift directory as it's not set for php5 as I only see include_path='.:/usr/share/php:/usr/share/pear' being in the include_path. Try moving them in one of these directories?
  7. I know, I just wanted to pester cssfreakie when he reads this
  8. For #2 I would advice to use normalize.css as per html5boilerplate. I have always found reset.css to be a bulldozer solution (but a necessary evil until normalize.css appeared). For #3 I really favor http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ although not everyone seems to agree. My 2 cents.
  9. so what do you suggest and any recommendations for frameworks? Zend's framework 2.0, Symfony 2, and also try Proem (thorpe's framework). Personally I'm more of a component freak myself so you may want to try these aswell: Doctrine 2 (db), Symfony components (good for Routing, Config, Autoloading, ..): it also has an HttpFoundation, translated this means that you can write your own bootstrap code and decide whether you'll route to an action in a controller (the default setting for most frameworks)?, a class?, a php file?, a closure? (I like this kind of flexibility even when I'll never need it ) Twig: because I hate Smarty. I have a few personal projects to get my feet wet with all the above frameworks and I mostly mix them all: use Zend's routing, Symfony's autoloading, Twig for templating, Doctrine for database, ..
  10. (The glass is half-full) Well, atleast you don't have to worry about the bugs anymore.
  11. Or use the Browser class. $browser = new Browser(); switch ($browser->getBrowser()) { case Browser::BROWSER_SAFARI: /* safari browser */ break; }
  12. No. Then would it be a Config class.
  13. Sorry too much code to weed through + I'm not going to spend any time optimizing this as you may disregard it afterwards anyway.
  14. You can keep using $ if you use self-invocation. (function($) { /* use $ without fear */ }); })(jQuery);
  15. The URL would look like: index.php/student/get/1 get in the URL has nothing to do with the variable. And you would access it like: class Student extends Controller { public function get($id) { $this->load->model('studentmodel'); $student = $this->studentmodel->find($id); $this->load->view('student/info', array('student' => $student)); } } This is how CI works.
  16. Upon trying to register.
  17. [sherlock holmes mode] Vlaams belgie? [/sherlock holmes mode] 5.647.000 of which 1.076.924 in Vlaams-Brabant, I'll see you soon then?
  18. I don't get how you could possibly still have troubles to make your website cross-browser compatible? I use a Browser class to detect the user's browser and add style rules accordingly. <body class="<?php print $this->browser->getCSSClassName(); ?>"> In your CSS you just add: .ie7 element { style } .ie8 element { style } /* etc */ cross-browser compatible every time Note though that I'm mainly a PHP developer, and every HTML/CSS developer out there will skin me alive if they ever find out where I live
  19. You can write perfect OO from scratch, you don't need anything. I don't think so, I have yet to meet a properly written forum. That's not crazy at all, a few old classmates wrote one in Java as a final project in college.
  20. Yup you can grab the node.exe (look under unstable) from the node.js website if you are using Windows. Or use Chocolatey.
  21. Nope, I never used SASS although I did know about it when I started using LESS.
  22. I use LESS instead of SASS together with Zen Coding and 960 CSS Framework. I "hate" writing HTML/CSS so anything that can get the job done quickly, I'm game.
  23. I prefer $page = isset($pageTo) ? $pageTo : 0;
  24. I have finally got around to actually start reading and writing some Python, Perl, and Ruby. Perl remains my favorite RegEx kung-fu Cleaning up a few projects.
×
×
  • 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.