Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. I then misinterpreted what you meant, sorry.
  2. public function loadPlugins($loadPlugins = null){ if(is_string($loadPlugins)){ $loadPlugins = explode(",", $loadPlugins); } $ini = $this->allpluginSettings(); if($loadPlugins == null){ foreach($ini as $sectionClass => $section){ require_once $this->location."/plugins/".$section['root']."/".$section['fileName']; $this->$section['instanceName'] = new $sectionClass(); $this->loadedFiles['plugins'][$section['root']]['path'][] = $this->location."/plugins/".$section['root']."/".$section['fileName']; $this->loadedFiles['plugins'][$section['root']]['files'][] = $section['fileName']; } } } This code, while an initial draft, isn't reusable nor properly tested: 1. You assume that any passed string is CSV 2. Once $loadPlugins != NULL you don't use it anywhere besides explode() it when it's a string which in turn isn't used anywhere. 3. $this->allpluginSettings() is called while the returned value is only used when $loadPlugins == NULL 4. Files are loaded through the require_once mechanism instead of a generic loader class 5. It's assumed the require_once will ALWAYS point to a file, and it will ALWAYS contain a class, so that $this->$section['instanceName'] = new $sectionClass(); never fails. 6. Exceptions/Error's aren't caught. 7. Using deep nesting $this->loadedFiles['plugins'][$section['root']]['files'] instead of using an object to represent the data structure. $myClass->example->someMethod(); still has the problem of no type-hinting unless you specify phpDoc @property comments on the class but since you are aiming for a plugin architecture this is not an option. No type-hinting is not only an IDE problem, it will also be hard for beginners to actually be able to understand why tutorials tell them stuff like: $o = new SomeObject(); while your framework loads it on-the-fly under a different name. If you want to teach beginners something, teach them how to program OO properly instead of showing them magic tricks. MyCoolFramework::create('User')->username('ignace')->password('foobarbaz')->authenticateSession()->setProfileAvatar(new Avatar('bar.png'))->save(); May look cool, but programming isn't about creating giant one-liners.
  3. @mikosiko Sharing addresses is not an option in this case, since: Assume I life on SesameStreet 7 with other students and 3 students are a customer: SesameStreet 7 | Student #1 SesameStreet 7 | Student #2 SesameStreet 7 | Student #3 Now Student #1 moves to Maryland 10 since only one record exists for SesameStreet 7 all are updated to Maryland 10: Maryland 10 | Student #1 Maryland 10 | Student #2 Maryland 10 | Student #3 One UPDATE just messed up your entire DB. I could even start adding addresses and then change them to my current address, now all your shipments are send to my home address (while I didn't pay for any of them).
  4. You can't serve the entire market (from beginner to advanced). Advanced users for example require functionality that reaches far beyond what beginners will ever need (ORM, DBAL, SOAP Client/Server, ..). Advanced users will also most likely use an IDE with type hinting of which it can't benefit if a large portion of your code is hidden behind magic methods like __call(), __set() and __get(). Both Symfony as CodeIgniter (Zend for it's action and view helpers) use this approach which I find annoying since I don't get a nice listing of available methods/properties.
  5. A user can have multiple addresses (home, work, ..). And multiple users can have the same address (colleagues, family members, students in the same house, ..). But you don't want to share addresses among users because when one edits his address, your packages may end up with the wrong customer. The relation therefor is: User (user_id, ..) Address (address_id, user_id, ..) You don't need the bridge table because each address is unique for each customer even if multiple customers live on the same address.
  6. Joomla is only one of many free available CMS systems. Take a look at the offerings on: http://php.opensourcecms.com/scripts/show.php?pagenumber=1 Select "Votes Cast (Most to Least)" from the dropdown.
  7. ~setWindowStatus\('(.*)'\)~ Will give you the text between the parentheses. If you are using SimpleXML you would do something like: preg_match('~setWindowStatus\('(.*)'\)~', $e->attributes()->onmouseover, $matches); // [1] => Lurkers, show your face
  8. We need some database information here, like do you have a field like PaulRyan suggests? One that keeps record on when they registered and when they activated? If you have then you can select all users like: "Now I need to send a follow up “Thank You” email 1 day after people have authenticated themselves" SELECT * FROM users WHERE activated_on = CURRENT_DATE - INTERVAL 1 DAY ".. and another email 1 week later with a basic survey regarding satisfaction so far." SELECT * FROM users WHERE activated_on = CURRENT_DATE - INTERVAL 1 WEEK @PaulRyan SELECT email,name FROM users WHERE activated = 'No' AND activation_time < $dayAgo That will select everyone with activated = 'No' regardless whether that was yesterday or last year.
  9. Looks good! I like it!
  10. I am running the same config. By default every account has no password. To set a password for an account you must do it through MySQL. Download and install HeidiSQL http://www.heidisql.com/ After installation, run it! You'll get the session manager, click New and give it a name (localhost for example) fill in 127.0.0.1 for the Hostname and root for the User, press Open. Click Tools, User Manager. In this dialog you can effectively manage the users on your MySQL install. Add a new user, give it a password and the necessary privileges and press Save. Enter the new username and password in the PMA config.
  11. You need to store it using sessions, so the value persists for the duration of the game. session_start(); // MUST be at the top of your script if(!isset($_SESSION['increment'])) $_SESSION['increment'] = 1; echo $_SESSION['increment']++; If you run this script you'll see the value increment every time you refresh the page. The value of 'increment' is persisted between requests.
  12. QuickOldCar you scare me! return "www"; EXIT; You do realise that EXIT; will never be executed, do you? $url = mysql_real_escape_string($_GET['url']); This will actually put FALSE into $url when it can't establish a MySQL connection (when mysql_connect() with zero parameters fails). You also don't need to call it since you don't actually store the value in MySQL. $parsedUrl[host] ? $parsedUrl[host] : array_shift(explode('/', $parsedUrl[path], 2)); No quotes around string indexes? Always place your functions at the bottom of your scripts so that it remains readable and understandable.
  13. ServerGrove? Also hosts Symfony
  14. We have tried to hand-code a text-correcting script, but it made it no further then the early beta's, never a real release candidate. But since you are now volunteering, we'll give you a nice shiny button below your name and the option to edit/correct/solve topics/posts (which is only possible when you are a moderator or higher on these forums). Contact Daniel0 and he'll provide you with further instructions on how to gain the new title.
  15. You have done no indexing, you just showed us your table schema. But yes, the schema is correct. Although you shouldn't mention that it's a table (User_type_table), it's obvious.
  16. Answers differ depending on your background. Your first concern should be performance. No matter how small/big your project, people won't tolerate a SLOW website. Often your website is SLOW due to bad or non-existent index definitions. Learn how to normalize your DB, and how you define proper indexes. Doing so, will save you lots of money down the road. Hardware-driven optimization is costly. 1) Keep it all in one DB, but keep in mind when writing your code that some tables may be switched to a different DB 2) Using an extra column to store the user_type is a well-known technique. The user_types themselves are best kept in a separate table and referenced using a foreign key to the users table.
  17. I agree with MrAdam, even if it's just for doing something like this: Array.prototype.inArray = function(value) { // }; Array.prototype.forEach = function(callback) { // }; var a = ['a', 'b', 'c']; alert(a.inArray('c')); var d = a.forEach(function(k, v) { return k+v; });
  18. If you ever get the chance, try it! The next time you start bashing out some PHP or C you already know what will be going on behind the scenes. Like a simple division by zero, which changes a "flag" on the CPU registry. You'll also start to understand how high-level/abstract PHP and C truly is, the notable difference in number of lines required to do something like a simple IF or FOR.
  19. You don't buy them from a store! yuk! Visit Brussel one time and eat those world-wide known lovely waffles!!
  20. Indeed, they are Brussels waffles
  21. LoL some OOP term? No. It was a joke. I never said I was funny!
  22. My first programming languages were Turbo Pascal, Assembler and COBOL (in that order). After my first encounter with COBOL I pulled out my shotgun (backpack) and pulled the trigger! Then I learned Java and C++
  23. 1. parse_url is by far the best solution. Avoid preg_match whenever you can. 2. $domain = ltrim(parse_url($url, PHP_URL_HOST), 'w.'); /*magic*/ This can become an issue if your domain is http://www.com (valid host name) but you can solve that like this: $domain = 'www.' . ltrim(parse_url($url, PHP_URL_HOST), 'w.'); /*magic*/ This will do the following: www.com =ltrim=> com => www.com domain.top =ltrim=> domain.top => www.domain.top www.domain.top =ltrim=> domain.top => www.domain.top
  24. SELECT * FROM profiles WHERE sex={$_GET['sex']} AND age>= 20 AND age<=30 ORDER BY pId DESC It's AND not ,
  25. The reason this happens is due to how a FLOAT is stored in memory. FLOAT has a loss in precision, it actually tells you how big the loss is: -2.8421709430404E-14 Therefor you should use BCMath, which gives you the correct result: print bcsub(245, getDiscount()); // returns: 0
×
×
  • 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.