dracoblue.net

How to validate an array with agavi

If you want to validate an array as parameter for an agavi action, you have to validate each of the array entries on its own.

Assuming we have an array called

options with the value as an array:

array(
  'title'=>'string text',
  'subtitle'=>'string subtext'
)

The following snippet validates it (every element is string - sorry for the laziness):

<validator class="string" required="true">
	<arguments base="options[]">
		<argument>title</argument>
		<argument>subtitle</argument>
	</arguments>
</validator>

Thanks to

v-dogg and wombert for the hints on how to make that.

In Agavi, Validator, open source, php by DracoBlue @ 2009-02-04 | 80 Words

retrieveByPKs undefined

Today we noticed that on some propel generated models the function retrieveByPKs was missing.

We found out that this was because of the fact that retrieveByPKs is only generated by Propel if there is only a single PrimaryKey!

In Propel, php by DracoBlue @ 2009-02-04 | 38 Words

DracoBlue.net relaunch

Hello,

it's been a while since I posted on my dev blog, real blog or at this site.

I had little spare time the past months, and so I focused on rewriting this page. Since that new page has a different database format I had to convert lots of data - which isn't done, yet. So if you inquery any problems glitches with the site - please comment or send via email!

Regards, Jan

In by DracoBlue @ 2009-02-03 | 74 Words

Creating (internal) links in Agavi Views-Templates

As you set up your routing.xml with some route like that:

<route name="[strong]unnamed_ticket_view[/strong]"
	pattern="[strong]^/ticket/(id:\d+)/$[/strong]" module="Tickets" action="View" />

You can easily create links directly to that with the following code (in your

templates):

echo '<a href="'.$ro->gen("[strong]unnamed_ticket_view[/strong]", array("[strong]id[/strong]" => [strong]12[/strong]))
	.'">'.htmlspecialchars("MyLink").'</a>';

This will create a link MyLink with the target

/ticket/12/, nice, isn't it? :)

In Agavi, open source, php by DracoBlue @ 2008-10-09 | 55 Words

Agavi database overrides for Propel + MySQL (other databases)

Once you generated your myproject-conf.php and myproject-classmap.php, you'll notice and copy and paste them into your app/config-folder you'll maybe want to set user and password for a specific AgaviPropelDatabase.

<?xml version="1.0" encoding="UTF-8"?>
	&lt;configurations xmlns="http://agavi.org/agavi/1.0/config">
	&lt;configuration environment="development">
		&lt;databases default="[strong]mydb[/strong]">
		&lt;database name="[strong]mydb[/strong]" class="AgaviPropelDatabase">
		&lt;parameter name="config">
			%core.app_dir%/config/[strong]myproject[/strong]-conf.php
		&lt;/parameter>
		&lt;parameter name="overrides">
		&lt;parameter name="connection">
		&lt;dsn>mysql:dbname=[strong]mydb[/strong];host=[strong]localhost[/strong]&lt;/dsn>
		&lt;parameter name="user">root&lt;/parameter>
		&lt;parameter name="password">&lt;/parameter>
		&lt;/parameter>
		&lt;/parameter>
		&lt;/database>
		&lt;/databases>
	&lt;/configuration>
&lt;/configurations>

Here you also can change the dns-entry to match different sql servers!

Your runtime-conf.xml for propel looks like that:

<?xml version="1.0" encoding="UTF-8"?>
&lt;config>
	&lt;propel>
		&lt;datasources default="[strong]mydb[/strong]">
			&lt;datasource id="[strong]mydb[/strong]">
				

<!-- 
					this ID must match <database name="">
					in schema.xml
				-->
				&lt;adapter>mysql&lt;/adapter> 
					

<!--
						sqlite, mysql, myssql, oracle, or pgsql
					-->
					
				&lt;connection>
					&lt;dsn>mysql:dbname=[strong]mydb[/strong];host=localhost&lt;/dsn>
				&lt;/connection>
			&lt;/datasource>
		&lt;/datasources>
	&lt;/propel>
&lt;/config>

In Agavi, Propel, open source, php by DracoBlue @ 2008-10-09 | 116 Words

Page 31 - Page 32 - Page 33