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

[eluser]backstack[/eluser]
[quote author="OverZealous" date="1283575859"]@backstack
You always need to first load the object before saving it. It also provides a nice safety net of verifying the input.

Alternatively, look at the update method if you are simply updating one or more objects and don't need validation or verification.

[/quote]

I'm sorry, I didn't really phrase my question well enough I don't think.

My problem is that, when I'm changing and saving on one variable (on my User model) (the 'activated' variable which corresponds to an 'activated' boolean column in the database, the validation for 'password_confirmation' is run (since I have the 'required' rule on it). This is problematic, since I just want to validate the 'activated' field (with the 'required' and 'boolean' rules) - I don't want the 'password_confirmation' rules running.

Thanks for your help. Smile

[eluser]Atas[/eluser]
[quote author="Lucas Alves" date="1283543391"]You have to set the "escape" to FALSE...

$oObject->select("publicacion.*, IF(moneda_id > 1, pub_precio * 1, pub_precio / 3.9) as result", FALSE);

I think this will solve you problem[/quote]

Hi, i changed the "escape" value to FALSE but didn't work... if i use $oObject->get() to retrieve the data works fine, but if i use get_paged() doesn't work... i receive this error:


Code:
A Database Error Occurred

Error Number: 1054

Unknown column 'result' in 'having clause'

SELECT COUNT(*) AS `numrows` FROM (`publicacion`)
   WHERE `publicacion`.`pub_confirmada` = 1 AND `publicacion`.`pub_tipo` = 'xxx'
HAVING `result` >= 1 AND `result` <= 500

The count query doesn't add the if statment...

Confusedhut:

[eluser]Unknown[/eluser]
First of all, thank you OverZealous for providing the excellent DMZ (and htmlform). For me they are super convenient and saves me a lot of work.

One issue though, in the function "delete()" in "Datamapper.php" (beginning at line 1959 or so), I would appreciate if you would check the return values from $this->db->delete() and return FALSE if they fail.

This gave me some problems with tables set up with foreign key constraints to prevent deletion. In my case, a delete operation of a row lead to this being intact (since the delete failed) and the relation key (_id) being set to NULL.

Cheers

[eluser]Lucas Alves[/eluser]
@Atas
I tested here and I got the same error as you. What's causing this is the Having clause, I don't know why it's changing the select statement... but if you remove the having clause it works well...

[eluser]Lucas Alves[/eluser]
@Atas

I found the "problem"... actually, it isn't a problem, it's a performance question. See the comment in the get_paged method:

// for performance, we clear out the select AND the order by statements,
// since they aren't necessary and might slow down the query.

I think it explain your question... Tongue

[eluser]Atas[/eluser]
@Lucas

Thanks lucas!, i am going to change that adding a new param to get_paged() function and if that param get false will not clear out the select. Or another option is override get_paged() in this specific model, this option is more clean i think...

[eluser]Lucas Alves[/eluser]
I think override the function is better... But maybe there's a way to do what you need without change the method...

[eluser]James McMurray[/eluser]
Quick (hopefully) question:

I've got a table where one of two values has to be non-null, while the other one must be null. It represents an image and the user can either upload it via the form or link directly to it. Is there a ways to set up a custom validation function that looks at two separate fields?

[eluser]OverZealous[/eluser]
Please see the included matches validation rule. But basically, you can easily configure a rule that does anything you want. To force validation, however, you'll probably need to add always_validate to your two fields.

[eluser]The Hamburgler[/eluser]
I've got a question about datamapper and php's __autoload function.

At the moment i have a call to __autoload() in config.php which allows me to have controllers extended from different classes.
e.g. some extend Public_Controller and others extend Admin_Controller.

The call to __autoload() enables me to automatically include these extended classes before the controllers are instantiated.

I'm looking to do the same for models, I have a number of classes that extend the datamapper class and I want to have my models extend these classes rather than datamapper directly.

At the moment, __autoload() is never called to preload the extended class when a model is instantiated so I get a Class not found error.
I could add each of these classes to autoload.php but this seems inefficient.




Theme © iAndrew 2016 - Forum software by © MyBB