Welcome Guest, Not a member yet? Register   Sign In
DMZ 1.7.1 (DataMapper OverZealous Edition)

[eluser]OverZealous[/eluser]
The example provided by DMZ is just a simple way to handle authentication - it doesn't provide any sort of authorization or framework. There's reason another auth framework couldn't be integrated, but it's not part of DMZ.

@Wazzu
For future reference, the "correct" way to order by a related field, which avoids table ambiguities, is:
Code:
$object->order_by_related('model', 'field');

This will also handle joining the related table if necessary. It also works with deep relationships.

[eluser]Wazzu[/eluser]
[quote author="OverZealous" date="1280182184"]@Wazzu
For future reference, the "correct" way to order by a related field, which avoids table ambiguities, is:
Code:
$object->order_by_related('model', 'field');
[/quote]
Thanks! that makes more sense :-)

[eluser]BRK Network[/eluser]
Hi Phil,

For example, Ion Auth looks like a great library and it is well-documented; but it has some overlapping functions with DMZ - like many other auth libraries. So, doing it the "DMZ way" sounds a lot logical to me.

In the meantime, will it be reliable to write an extension for auth and user management? Or will it be better to write a library from scratch - but which requires DMZ to work?

[eluser]gyo[/eluser]
Hi OverZealous,

That's exactly what I mean.
I'd like to add a login alias into the User model, and only run the validation within DMZ, without doing the 'get'.

Is it possible to do just $this->validate(); ?

Thanks again!

[eluser]OverZealous[/eluser]
@BRK Network
This is up to you. There's no right or wrong way. It depends heavily on your application design, experience, and time constraints.

@gyo / suashi
Yes, you can manually validate the object.

[eluser]frist44[/eluser]
Is there a way to validate a select number of the fields? IE. I have a login form with username and password. If I run validate on it, it will not pass because it's processing on the other fields in the database table (email, address...), but for form only has the two. I want to guard against people submitting a textbox with nothing in it so I don't query the database.

[eluser]OverZealous[/eluser]
@frist44
You don't need to pass validation for the login to work. See the example application included with DMZ for a fully-functional example.

validate()->get() doesn't attempt to pass validation - it simply allows the validation routine to process the fields.

[eluser]frist44[/eluser]
The example relies on this:
Code:
if($this->input->post('username') !== FALSE)

to ensure the field is completed. I guess my point is that if the password field has a min_length rule of 6, and someone inputs something with 3, it's still going to query the database as if it's a valid value. It will obviously not come back with anything because there will be no passwords in the database <6, but still, it's one more query that you have to run knowing it'll fail. It seems that maybe something against the validate() method where you could select fields might be beneficial.

Thoughts?

[eluser]uptime[/eluser]
I think I've found an issue with DMZ and PHP > 5.3.0.

Example code:
Code:
$m->include_related('some_model', NULL, TRUE, TRUE /* instantiate */);

Code:
var_dump( $m->some_model->exists() ); // Outputs TRUE, however, the data does not exist (NULL);

After some debugging, I've found that DMZ may not instantiate the related model correctly due to a PHP bug.

Bugfix/Workaround:

In _to_object(), replace:

Code:
foreach ($this->fields as $field)
{
    if (! isset($row->{$field}))
    {
        $item->{$field} = NULL;
    }
}

With the following:

Code:
foreach ($this->fields as $field)
{
    //if (! isset($row->{$field}))
    
    /**
     * Workaround for PHP > 5.3.0
     *
     * Please let me know if you have any comments, suggestions or updates;
     * I hope my issue wasn't due to misuse of DMZ. Issue occurs on PHP 5.3.2;
     *
     * @author [email protected]
     * @see http://bugs.php.net/49269
     */
    if (! isset($row->{$field}) && ( is_array($row) && ! isset($row[$field]) ) )
    {
        $item->{$field} = NULL;
    }
}

It fixed my issue on PHP 5.3.2.

Did anyone else have such an issue?

Edit: The correct way of fixing this would probably to use the __isset() magic function on the DataMapper object to prevent the same issue from happening again.

[eluser]Jfly[/eluser]
May I ask one question?

After I add include_related(), DMZ generates a wrong SQL statement. It duplicates the joined table name.

The problem happens in:
Code:
... LEFT OUTER JOIN `xxx` xxx ON ...

If I remove the second "xxx", the SQL statement can be run in phpMyAdmin.

Is there anyway to fix this?

Thanks a lot.




Theme © iAndrew 2016 - Forum software by © MyBB