Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. If your looking to implement a bussiness critical application on CodeIgniter... DON'T. CI isn't made for such applications merely for people new to (web-)software development and you'll find a great bottleneck in CI when you do. Zend on the other hand has the muscle you need to run a large e-commerce project mostly because it's backed by a big company that provides training (for those new team-members you'll employ in 2 years).
  2. Something to get you started $postOffice = new PostOffice(); $message = new Message($_POST, $sender); $postOffice->distr($message, $receivers);
  3. REST uses HTTP which makes it very lightweight, a few examples of REST: -- create the user PUT /users Host: www.phpfreaks.com Accept: text/xml Accept-Encoding: UTF-8 username=ignace&password=password -- read the user info GET /users/ignace Host: www.phpfreaks.com Accept: text/xml Accept-Encoding: UTF-8 Authorization: user ignace:password -- update the profile info POST /users/ignace Host: www.phpfreaks.com Accept: text/xml Accept-Encoding: UTF-8 Authorization: user ignace:password avatar=RESTful.jpg&signature=Posted%20Using%20REST -- delete it DELETE /users/ignace Host: www.phpfreaks.com Accept: text/xml Accept-Encoding: UTF-8 Authorization: user ignace:password Full CRUD-functionality.
  4. That's where we differ. I'm a whore. Yup, me too. I wonder, how much do you charge?
  5. That's the best part, we do this for free You can of course send a small donation to support this website.
  6. Although you took a good turn with the Page class you'll want to zoom out and group some related functionality (high cohesion) together. Like: Controller: class UserController extends BaseController { private $storage = null; // DataAccessObject or something else function add($options) { $user = UserFactory::create(); $user->setEmailAddress($options->email_address) ->setPassword($options->password); $this->view->setFaultCode($this->storage->save($user), $options); } function edit($options) { $user = $this->storage->findByEmailAddress($options->email_address); $this->view->setFaultCode($this->storage->save($user->modify($options)), $options); } function remove($options) { $this->view->setFaultCode($this->storage->delete($options->email_address), $options); } } View: <?php if($this->hasFaultCode()): ?> <p class="error"><?php print displayNiceError($this->getFaultCode(), $this->getOptions()); ?></p> <?php endif; ?> View Helper: function displayNiceError($code, $options) { $message = SomeService::getMessageFor($code); return $translator->translate($message, $options); } Something along those lines, I'm partially experimenting here with possibilities.
  7. Or you selected Archive as an export option which sets the Archive engine which is read-only.
  8. It depends if both are related then you could do: require 'a.php'; class b extends a If they are not then you must ask yourself will a exist outside of b? Yes then require 'a.php'; class b { function __construct(a $a) otherwise: require 'a.php'; class b { function __construct() { $this->a = new a(); } }
  9. Now that you have solved that you may want to try The million dollar problems (you get a million dollar if you can solve one of them)
  10. OOP is about encapsulating your data, which means that the data is hidden from the client. If you declare your class variables public you are no longer encapsulating this data. It's best to always declare your class variables private NOT public and only in VERY rare cases should you use protected.
  11. The proper method would be: class SomeOddWorld { private $theOddWorldsName; public function __construct($nameIt) { $this->theOddWorldsName = $nameIt; } } Ditch the getHtml() method it's against proper design. Every model should be free of storing and presenting itself.
  12. Other options available: <input type="submit" name="99" value="MyUsername" onclick="this.value = this.name; this.name = 'userid';"> ----- <input type="hidden" name="userid" value="99"> <input type="submit" value="MyUsername"> Both are handled like: $userid = $_POST['userid']; The latter is better if you want to support graceful degradation.
  13. Meet the <button>: <button type="submit" name="userid" value="<?php print $userid ?>"><?php print $username ?></button>
  14. $iterator = new RecursiveArrayIterator($root); foreach(new RecursiveIteratorIterator($iterator) as $node){ echo $node->current(), "<br>\n"; }
  15. Oof. I think I just threw up in my mouth a little bit. OK, it was actually a lot. U DOAN LIEK FRENCH FRIEZ WIF MAYONAIZE?
  16. But, the problem is hoofdfoto (main picture) will not always be 1 so if i write: SELECT pd.pandenid,ft.filename,max(ft.volgorde) AS volgorde FROM panden AS pd LEFT JOIN fotos AS ft ON pd.pandenid=ft.pandenid AND ft.hoofdfoto=1 WHERE ft.filename IS NOT NULL GROUP BY pd.pandid ORDER BY pd.pandid,if(ft.hoofdfoto=1,ft.hoofdfoto,volgorde) DESC I only get the records which have ft.hoofdfoto=1 while it should take the highest value for volgorde if hoofdfoto=0 so something like ON pd.pandenid=ft.pandenid AND (ft.hoofdfoto=1 XOR ?). But I have no clue as to how I could achieve this. Maybe ft.volgorde=volgorde (with an OR instead of XOR)?
  17. The last query I tried was: SELECT pd.pandid,ft.filename,max(ft.volgorde) AS volgorde FROM panden AS pd LEFT JOIN fotos AS ft ON pd.pandid=ft.pandenid WHERE ft.filename IS NOT NULL GROUP BY pd.pandid ORDER BY pd.pandid,if(ft.hoofdfoto=1,ft.hoofdfoto,volgorde) DESC Except it ignores ft.hoofdfoto entirely while it should favor ft.hoofdfoto if it's value equals 1 @fenway damn I really would have wanted to do this in one query, thanks
  18. Hi, I have 2 tables: panden id, pandenid, .. fotos id, pandenid, hoofdfoto, volgorde I now want to construct a query that takes the picture that has hoofdfoto=1 or when it has no such value for that field it should take the highest number stored in volgorde. I tried SELECT pd.id,ft.filename,max(volgorde) FROM panden AS pd LEFT JOIN fotos AS ft ON pd.pandenid=ft.pandenid GROUP BY pd.pandenid Without any luck. I am not even sure this is possible as the system is MySQL v4.0 which can't be upgraded because the application that uses it is very unstable and they have no idea what kind of implications it may have, another reason is the number of users that use the system daily. Regards, Ignace
  19. I don't know where you have worked but in my experience that's hardly ever the case. In most cases you participate in the planning of projects and get the opportunity to discuss features.
  20. class ParagraphDAO{ private $database=null; public function __construct($database){ $this->database=$database; } public function findById($id){ $id=$this->database->real_escape_string($id); $query="SELECT * FROM table WHERE id=$id"; $result=$this->database->query($query); return 0!==$result->num_rows()?$result->fetch_object('Paragraph'):null; } }; class NewsBox extends HtmlModule{ private $paragraph=null; public function __construct(Paragraph $p){ $this->paragraph=$p; } public function render(){ return '<div class="">'. '<h3>'.$this->paragraph->getHeadline().'</h3>'. '<img src="http://domain/images/'.$this->paragraph->getImage()->getFilename().'"'. ' alt="" style="float:right">'. '<p>'.$this->paragraph->getOpening().'</p>'. '</div>'; } }; class Paragraph{ private $id=0; private $headline=''; private $image=null; private $opening=''; public function __construct($id,$headline,$image,$opening){ $this->setId($id); $this->setHeadline($headline); $this->setImage($image); $this->setOpening($opening); } public function getId(){ return $this->id; } public function setId($id){ $this->id=$id; } public function getHeadline(){ return $this->headline; } public function setHeadline($headline){ $this->headline=$headline; } public function getImage(){ return $this->image; } public function setImage($image){ if(file_exists($image)) $this->image=new SplFileInfo($image); } public function getOpening(){ return $this->opening; } public function setOpening($opening){ $this->opening=$opening; } }; Use as: $mysqli=new mysqli(..); $dao=new ParagraphDao($mysqli); $paragraph=$dao->findById(1); $nb=new NewsBox($paragraph); echo $nb->render();
  21. RSync: # can update whole directory trees and filesystems # optionally preserves symbolic links, hard links, file ownership, permissions, devices and times http://samba.anu.edu.au/rsync/features.html
  22. They haven't figured it out yet.
  23. $mysqli->query('SET time_zone = "Europe/Stockholm"'); .. $mysqli->query('INSERT INTO ..');
×
×
  • 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.