Jump to content

Search the Community

Showing results for tags 'factory'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. So I have a few tables configured in Propel, with generated Peer static classes. This is the framework I have to use and I cannot change it. The problem is that I need to perform very similar search operation on different tables, that obviously have different Peer classes. This lead to duplicated code. Now, I am not such that great guru of PHP, so maybe there is some construct (avoiding eval) that might help me in this case; I really would like to avoid writing duplicated code that performs the same exact calls on just different static Peer classes. example from a method of a class I am writing: $criteria = new Criteria(); $criteria->add(FoobarPeer::CONTRACTNR,$data['contractnr']); $result = FoobarPeer::doSelect($criteria); if(count($result) > 1){ throw new FoobarException("status: more than one row with the specified contractnr."); } if(count($result) == 0){ // no object with given contractnr. Create new one. $obj = $this->factory->createORM("foobar"); $obj->setCreatedAt(time()); } else { // use and update existing object. $obj = $result[0]; } (as you can see I managed to write a factory method for the row object, but obviously I cannot do this for static classes) Anyone got some nice solution? thanks P.S. sorry for my approximative english
  2. So I am working on an MVC application where the controller methods instantiate a factory that is suppose to return a model. In this case, the factory methods do some kind of work with a database or API to save/get/ data which then is placed inside a model and returned by the method. So lets say I have a factory method called createUser(email, password); Now I am going to call this method in the controller. I want my controller lean and mean and not fat! The model can be fat but NOT the controller and so my methods for validation at the moment are inside the model. Where do I call this validation? Inside the controller before the factory? Inside the createUser() method in the factory before it does it's database and api work to return a model??? Where?!? Here are two scenarios that come to mind: -Instantiate the User model inside the controller method before the factory and validate the input data. If it returns without any problems, send it to the factory to return a model of the User with the newly created data. -Instantiate the factory, call createUser(input data) and inside the create user method, do the model validation first before getting/saving the data to an API or database? If the validation fails in the createUser() method, return a model with error messages and any of the bad data. If their are no validation problems, return a model.
×
×
  • 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.