Skip to content

Add a subquery as where clause to your propel criteria or statement?

So you are still using the propel - the blazing fast php orm but you want to narrow/scope your result by a complex/not daily condition?
No problem you can use a subquery and put it to the where condition area.

$mySubqueryForFoo = '(
        ' . FooPeer::TABLE_NAME . '
        ' . FooPeer::BAR_ID . ' = ' . BarPeer::ID . '
) > 0';

//if you are using the criteria object

//if you are using the query object

Translate to de es fr it pt ja

PHP Propel - add a column (with a sub select) to an result

Assuming you want to add a counting column like "numberoffoo" but you want to use your propel environment. Propel, of course, provides a way how you can achive this.

$criteria = new Criteria();
        ' . FooPeer::TABLE_NAME . '
    ' . FooPeer::BAR_ID . ' = ' . BarPeer::ID . '); )

"Quelle surprise", propel can deal with that also in the cooler query way.
$result = BarQuery::create()->addAsColumn(
        ' . FooPeer::TABLENAME . '
        ' . FooPeer::BAR
ID . ' = ' . BarPeer::ID . ');


Translate to de es fr it pt ja

create simple and reusable validators using the php requirement component - php component requirement 1.0.4 released

I updated the requirement component to 1.0.4. The new version contains the validator example. By creating this example, i added two new features for upcoming releases, so stay tuned :-).

The example is shipped with a validator collection which contains all needed validator items. It would definitely make more sense, if you would name that validator collection more specific like "IsValidTableForGermany" (or "IsValidUserName" if you want to switch context). All validator items need a injected table example class. Since the requirement component is dealing with automatically injection, you don't have to take care about this :-).

As you can see in the example class, all you have to do is to inject the item you want to validate and call "isMet()". The example itself creates a bunch of tables by choosing random properties.

What are the benefits of using the requirement component also for validation? Reusable and simple testable validator items and a endless flexibility of item combination by using the power of existing and and or condition.

  • add example to use the component as validator

Enjoy it :-).

Translate to de es fr it pt ja

php component requirement 1.0.3 released

Version 1.0.3 of the requirement component for php is released. Changes are listed below.

  • add caching for magic __call condition in abstract method to not iterate over each item (invalid cache if new item is add)
  • Refactored locking by using lock component

Enjoy it :-).

Translate to de es fr it pt ja

php component requirement - version 1.0.1 released

Version 1.0.1 of Requirement Component for php is released. Changes are below.

  • Added annotations to example requirement
  • Added return value $this to magic __call methods of requirement and condition
  • Added return value $this to addItem method of ConditionInterface
  • Added return value $this to addCondition method of RequirementInterface
  • Added lock and isLocked method to RequirementInterface, RuntimeException is thrown if addCollection is called and requirement is locked
  • Updated Readme with explanation of provided examples
Translate to de es fr it pt ja

php component requirement - transfer business logic into code like a breeze

Reason Of Development

As a php developer, i have to deal with a lot of refactoring tasks day in and day out. Refactoring includes not only code refactoring but also business logic refactoring. A team member right now had figured out a general problem and we all knew that we have to put "the chaos into a cage" because of the following reasons:

  • Developers are lazy and want to call a simple method instead of rewriting complex expressions
  • After we found strange parts of code, we want to put that into a sentence to spot the business logic
  • We want to have a generic component where you can reuse business items
  • Since business logic can became nested, the component should handle this

After we (take a look to the credits please) tied up the requirements, it took some time to get a feeling of how to put this into classes. After a while, i had a longer talk with a team member and he presented me his idea. I liked his idea but found some drawbacks. Since it this is a normal way of coding, it really isn't a fault of the team member (and i'm also not a better programmer then he), but thats how this component was initial created. While i was on my way back home, i had some ideas how to keep things simple and generic and started that project. On the next day, jens joined me and we quickly made some progress and where able to tag version 1.0.0 pretty soon.

Common Terms And Names

To understand the component, it is worth to know about the used terms and names. We finally decided to use the following ones.

  • Requirement: Thats the class you want to work with. Extend it or use it straightaway via a factory. This class represents the business logic with all "and's" and "or's"
  • Condition: After reading and writing business logic, each is full of "or's" or '"and's". Thats why we provide two condition that are used to handle collections of business items (simple rules)
  • IsMetInterface: To keep it simple, when you implement a business logic or validate against one, you only want to know "is this requirement met or not", so thats what the interface is for. This interface is implemented in the Requirement as well as in the Condition and you have to implement it in your item as well
  • "()" are used to represent an and condition: ("foo", "bar") is "foo and bar"
  • "[]" are used to represent an or condition: ["foo", "bar"] is "foo or bar"


The component is shiped with some examples. Feel free to pull some more. Nevertheless, to use this component, you have to do the following steps (and yes, this is already the example ;-)).

  • Try to sum things up by writing a sentence like: "The user mets our requirement if he is interested in OOP or big data and if he loves open source software, has no problem to read man pages or use his favorite internet searchengine or if he is already a maintainer or a contributor to an existing open source project"
  • Slice out the items that matters: "OOP", "big data", "loves open source", "read man pages", "use favorite internet searchengine", "maintainer", "contributor"
  • Create classes for each item that implements the IsMetInterface and that provides a usefull setter method
  • Collect the items into conditions: [(["OOP", "big data"], "loves open source"["read man pages", "use favorite internet searchengine"]), ["maintainer", "contributor"]]
  • Create the items and inject them to the right conditions, be aware of the fact that you even can inject conditions into conditions (meaning combine a condition with another)
  • Implement this into an class that extends the Requirement class or let it be assembled via a factory

Hints For Using And Developing

All in all you have to implement a setter method to your item. You can create setter methods in your requirement or simple use annotation. The requirement class and the condition classes are using the magic __call method to hand over the call from the requirement through the condition to the item.

If you want to create a requirement class that assembles itself or use a factory is a decision you have to make.

Download And Install


git clone

require: "net_bazzline/component_requirement": "dev-master"


Thanks to Mihai Andrei Cosma - this is your idea, developed by ourselves :-).

Translate to de es fr it pt ja

php storm earth day nice price until 22. of april 2013

Ever tried php storm and thought about purchasing this software? Well, it could be your week. The Personal License is available for 53 Euro (exklusive VAT). Go to the page and purchase.

PhpStorm is also available as aur package.

If you want to use build in update mechanism, go to /opt/phpstorm and try the following. create a group called developer by using "groupadd developer". Add your useraccout to the group by using "usermod -a -G developer myUser". Since you are in "/opt/phpstorm", you now have to change the group from root to developer by using "sudo chgrp -R developer *". After that you have to add the write right for the new group by using "sudo chmod -R g+w *". Thats it, happing using.

Getting the following error:

raspberry pi openpvn

and thats why you have to start phpstorm via console?

Open /opt/phpstorm/bin/ and search for following line.

# --------------------------------------------------------------------- # COMMENT LINE BELOW TO REMOVE PAUSE AFTER OPEN JDK WARNING # --------------------------------------------------------------------- read IGNORE

Change it to.

# ---------------------------------------------------------------------



comment line by artodeto 130418


Translate to de es fr it pt ja

tool - serendipity syntax plugin highlighting

After seeing syntax highlighting by a friend, i decided to update my serendipity also. After a little bit of trying, i am now using "Prettify for S9Y (serendipityeventprettify)".

How to use it? Quite simple, install it and use "<pre class="prettyprint lang-foo">your code</pre>" to cover your codeblock. The following languages are supported right now:

lang-bsh lang-c lang-cc lang-cpp lang-cs lang-csh lang-cyc lang-cv lang-htm lang-html lang-java lang-js lang-m lang-msml lang-perl lang-pl lang-pm lang-py lang-rb lang-sh lang-xhtml lang-xml lang-xsl

By the way, you also get a fancy button on the "create entry page" for free. Just mark a text and click the button and magic javascript is encoding your html entities for you.

Translate to de es fr it pt ja

work - pair programming

What a session, my team and obviously i finished a pair programming task and it was such a joy to work that way. It feels like a race against each other but you are absolutely happy when you crossed the finish line as team!

A great fun, but as on every race, you are a bit drained when you finished ;-).

And by the way, you are feeling like "going to swim without life jacket" when you commit your code without a unittest so that a teammate can work and test with the code :-D.

Translate to de es fr it pt ja

php - how to explode a string with multiple delimiters without using preg_split

The task is to split a string by a set of delimiters. pregsplit could be an option but there is an easier way ;-). Why not combine strreplace and explode?

First, we replace all known delimiters with a special (and hopefully unique) string. After that, we have a string with one delimiter, so it became a suitable task for explode. Take a look to the sourcecode below.

<\?php $nl = PHP_EOL; $string = 'Word1, Word2 , Word3 and Word4 or Word5 oder Wort6 / Word 7 Word-8'; $delimiters = array( ', ', ' , ', ' oder ', ' or ', ' / ', ' und ', ' and ' ); $words = array(); $unionPlaceholder = 'ARTODETO_BAZZLINE_NET_UNION_PLACEHOLDER'; $unifiedString = str_replace($delimiters, $unionPlaceholder, $string); $words = explode($unionPlaceholder, $unifiedString); echo 'splitting following string:' . $nl . '"' . $string . '"' . $nl; echo '----' . $nl; foreach ($words as $word) { echo $word . $nl; }

You see, no magic but a possible timesaver. Have fun with it.

Translate to de es fr it pt ja