Welcome Guest, Not a member yet? Register   Sign In
[Deprecated] DMZ 1.6.2 (DataMapper OverZealous Edition)

[eluser]Conerck[/eluser]
[quote author="OverZealous" date="1266472786"]@Conerck

Edit: Scratch what I said, I realize the problem.

I understand your concern. If you want to make a query like that, you should be checking the result of:
Code:
count($object->all)

I'll think about the alternative, but the real purpose of the exists method is checking the existance of a single object.[/quote]

Right, but if I have a Table with a composite key or some UNIQUE constraint that allows me to make a single row query without the use of the ID field I run into the same problem.

Basically, if the method was called has_id(), I wouldn't complain, but since it is called exists() it implies a certain semantic meaning, which in some conditions breaks.

Edit: As I said above, in the short term I could live with a warning in the User Guide. I just took me a while to figure out why my code wasn't doing the things I expected and this was the reason. I expected my uniquely identified record to exist and DMZ told me it didn't ;p

[eluser]OverZealous[/eluser]
Honestly, that is a tiny bit outside the intended design of DMZ. (When you work outside the design, you should expect some things to not work the same.)

As I said, I'll look into a change. I think this would work pretty well:
Code:
return !empty($this->id) || (count($this->all) > 0);

Which should have not performance impact on existing code. I also can't see how it would break anything, unless someone is doing something weird with ->all. The all array is always empty unless something was returned with a query.

It's a good find.

[eluser]Conerck[/eluser]
I wouldn't call it outside the intended design. Unless you'd say that if someone wants to use a String, a timestamp, a GUID or one of the many other options for keys as an alternate or replacement to the autoincrement id as outside the intended design, in which case I'd have to say that the design scope is too narrow.

Oh and also exist() should break if you do a query with LIMIT 1 and don't include 'id' in your select()... THAT at least should be an intended use case Wink

Anyway, the fix looks good. Thanks for the quick response, once again. There might be other frameworks out there that have more blows and whistles and whatnot, but your dedication makes DMZ a top choice.

[eluser]tdktank59[/eluser]
[quote author="tdktank59" date="1266200165"]Hey

So ive got a small issue, that ive noticed before... as well.

When you try and save a single field it runs through the entire validation check and ends up error-ing out on fields that I don't care about at that point.

Is there a way we can either make this only check the passed in fields (best solution in my mind, and since then it only checks what we want it to.) Otherwise a way to define which validations to run for a specific insert.

Because im having an issue where ive got a few fields, for some reason or another a field gets blanked out and I try and update it again and it says cannot update because some other field is required that is blanked out as well.

Thanks.
[quote author="OverZealous" date="1266283645"]@Oblique
@tdktank59
Either you are not loading the object before you are saving it, or you are setting individual fields to NULL after loading it. DMZ only checks and saves the columns that have not changed since the last get or save.[/quote][/quote]


@OverZealous

Here is what im doing that is causing the issue.
This is just a general ajax edit function
Basically Id send it the $field and the $value and a $user_id and the $table (user/user_info).
Based on all that it would load the $table, look up the user (id/user_id)
and save the $field and $value.

However it returns an error for a field that it should not be caring about, and clears the value out of $field.
The other field is set to require and due to this problem I'm stating, it removes the value on a failed update and then causes more problems.

Heres the code:
Code:
$u = new $table();
$u->where($column,$user_id)->get();
$u->{$field} = $value;
if ($u->save())

[eluser]OverZealous[/eluser]
@tdktank59

The validation rules run if:
1) It is a related rule, OR
2) There is no stored value (ie: new, unsaved object), OR
3) The current value does not match the stored value

If it is a related rule, then it runs always, because it isn't possible to check against a stored value (currently).

Otherwise, as long as you get() before you save(), OR you don't get() but don't set the field, the validation rule is not run.

I don't know what else to tell you. Try setting up your code outside the current setup, with hard-coded columns and values, and see if you get the issue.

(Man, I hope all that user-submitted data is being checked thoroughly!)

[eluser]tdktank59[/eluser]
[quote author="OverZealous" date="1266482346"]@tdktank59

The validation rules run if:
1) It is a related rule, OR
2) There is no stored value (ie: new, unsaved object), OR
3) The current value does not match the stored value

If it is a related rule, then it runs always, because it isn't possible to check against a stored value (currently).

Otherwise, as long as you get() before you save(), OR you don't get() but don't set the field, the validation rule is not run.

I don't know what else to tell you. Try setting up your code outside the current setup, with hard-coded columns and values, and see if you get the issue.

(Man, I hope all that user-submitted data is being checked thoroughly!)[/quote]

LOL Yes it is being checked... I removed all of the code that is doing that sort of stuff for this post.

[eluser]NachoF[/eluser]
Ok Im trying to use form generation library but im just getting a bunch of weird errors...

heres my method

EDit: I just realized that it is outputting php raw code in my html.. I think its because they are not using full <?php tag but instead just <? tag.. how can I fix this?

heres some of the html code that shouldnt be there.
Quote:<?
if( ! isset($save_button))
{
$save_button = 'Save';
}
if( ! isset($reset_button))
{
$reset_button = FALSE;
}
else
{
if($reset_button === TRUE)
{
$reset_button = 'Reset';
}
}; ?>
<? if( ! empty($object->error->all)):; ?>
<div class="error">
<p>There was an error saving the form.</p>
<ul>&lt;? foreach($object->error->all as $k => $err):; ?&gt;
<li><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message: Undefined variable: err</p>
<p>Filename: libraries/Loader.php(673) : eval()'d code</p>

<p>Line Number: 21</p>

</div></li>
&lt;? endforeach; ?&gt;
Code:
function Create()
        {
            $user = new User();
            $data['user']=$user;
            $user->load_extension('htmlform');        
        $form_fields = array(
            'name',
        );
            $data['form_fields']=$form_fields;
            $this->load->view('users/create',$data);
        }

heres my view
Code:
&lt;?php
    echo $user->render_form($form_fields);
?&gt;

Here is part of the long list of errors
Quote:error->all)):; ?&gt;

There was an error saving the form.

* error->all as $k => $err):; ?&gt;
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: err

Filename: libraries/Loader.php(673) : eval()'d code

Line Number: 21

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: row_class

Filename: libraries/Loader.php(673) : eval()'d code

Line Number: 52
"
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: row_id

Filename: libraries/Loader.php(673) : eval()'d code

Line Number: 52
>
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: label_for

Filename: libraries/Loader.php(673) : eval()'d code

Line Number: 53
>Name:
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: save_button

[eluser]OverZealous[/eluser]
@NachoF

2 things:
1) I no longer support the HTMLForm extension. There's some messages about this on this forum.

2) If you want to change the HTMLForm templates (which have the short tags), feel free to do so. They are just samples, and it was expected, from the beginning, that you would edit the templates. Alternatively, enable short tags in php.ini.

Most likely your errors are related to the short tags.

[eluser]NachoF[/eluser]
Yes, it was the short tags... Ive fixed it...
What do you mean you no longer support them?.. You dont encourage its usage anymore?

[eluser]OverZealous[/eluser]
I mean exactly that I don't support it. ;-) You can use it, you can modify it, etc, but I am not planning on updating it anymore, nor will I provide technical support. 8-/

The reason is, almost half of the problems I have had reported here were with the HTMLForm extension; it is almost as complex as DMZ itself. I tried to get someone to take over, but I haven't had any luck.

(Another reason I can't truly support it is that I don't use it myself. I have my own toolkit I developed long before I even took over DataMapper, and it has a completely different design.)

Hamburgler created his own variation on the concept, but it is a lot different.

So, I don't exactly discourage it's usage. If you already use it, great! But I'm probably not working on it anymore. I'll continue including it with DMZ for the foreseeable future, and it will still be part of the example app ('cause I'm not rewriting that!). The next release will have a disclaimer about it.

Hopefully that makes sense.




Theme © iAndrew 2016 - Forum software by © MyBB