CodeIgniter Forums
DataMapper 1.6.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: DataMapper 1.6.0 (/showthread.php?tid=11358)



DataMapper 1.6.0 - El Forum - 02-27-2009

[eluser]OverZealous[/eluser]
OK, looked into it some more. Sorry about the confusion, I don't use auto-transactions, so I misunderstood what is happening.

It is definitely a bug of sorts. The 'transaction' error message is only set if the transaction itself fails (which it never should, unless something really bad is happening on the server!)

To work around it, you should check to see if the transaction error has been set:
Code:
if(isset($obj->error->transaction)) {
    // show transaction error
}

You could also fix this by adding this line into the DataMapper souce:
Code:
// around line 1015
        }

        $this->error->transaction = ''; // <<< Add This Line

        // Clear this objects "has many" related objects
        foreach ($this->has_many as $related)

I'll add a fix into my testing copy of DataMapper that I am working on.


DataMapper 1.6.0 - El Forum - 02-27-2009

[eluser]tdktank59[/eluser]
delete


DataMapper 1.6.0 - El Forum - 02-27-2009

[eluser]OverZealous[/eluser]
Where are you seeing the translation error? Usually you can just specify the table name by hand, and that fixes the issue (that's how I do it, and I use the model Status/Statuses).

There is no real catch-all to fix pluralizing English words, without some large dictionary. It's better just to hard-code those few outliers.


DataMapper 1.6.0 - El Forum - 02-27-2009

[eluser]tdktank59[/eluser]
True... However for some reason status and statuses wasnt working for me...

Here however might be the fix for it if you want to add it to the inflector...

add to singular before the else
Code:
elseif ($end2 == 'es' && strleng($str) > 4)
{
     $str = substr($str,0,-2);
}

change
Code:
elseif (in_array($end1, array('h', 'o', 'x')))
to
Code:
elseif (in_array($end1, array('h', 'o', 'x')) OR $end3 == 'tus')



DataMapper 1.6.0 - El Forum - 02-27-2009

[eluser]tdktank59[/eluser]
Heres what happens with status

Quote:Unknown column 'join_brainstorm_statuses_brainstorms.brainstorm_statu_id' in 'on clause'

ignore the brainstorm stuff...

and yes its defined in my model.

Code:
class Brainstorm_status extends DataMapper
{
    var $table = 'brainstorm_statuses';

    var $has_many = array("brainstorm");

ALlright I found the problem!
For some reason when its getting the $common_key gets the singular and it takes the s off the end... since its not "plural"

Solution is to change this line: (line 75 to 81 for me)
Code:
else
{
    if ($end1 == 's')
    {
        $str = substr($str, 0, -1);
    }
}
to
Code:
else
{
    if ($end1 == 's' && $end2 != 'us')
    {
        $str = substr($str, 0, -1);
    }
}



DataMapper 1.6.0 - El Forum - 02-27-2009

[eluser]OverZealous[/eluser]
If you don't want to edit the pluralizing code, you can simply hard code both the model and the table:
Code:
$model = 'status';
$table = 'statuses';

This should fix everything else, unless you have a self-reference between 'statuses' (although, I think that works as well). That's the only other time that plural() is called, and singular() is only used on declaring the model.


DataMapper 1.6.0 - El Forum - 02-28-2009

[eluser]Daniel Moore[/eluser]
Can we get the DataMapper user_guide in downloadable format? I am sometimes developing while away from an internet connection to maximize my time, which is one reason I love CodeIgniter so much, the documentation can be local on my machine. Also why I like DX Auth, it has the documentation downloadable.


DataMapper 1.6.0 - El Forum - 02-28-2009

[eluser]OverZealous[/eluser]
Every copy of DataMapper (stensi's) includes the User Guide. If you have DM, you have the User's Guide.


DataMapper 1.6.0 - El Forum - 03-02-2009

[eluser]stefanv[/eluser]
[quote author="OverZealous.com" date="1235784264"]
While I like your idea, it would break a lot of existing code that expects a string on the fields. Why are you getting multiple errors per field? I'm pretty sure DataMapper's validation routine stops as soon as any field has an error.[/quote]

When i add multiple check on a field (like minlength, maxlenght and uniqiue) 1 get 3 errors, but the $this->error->{fieldname} only shows the latest error that was found.
I want to show all errors and not only the latest one found.

I agree it would break a lot of code, but i found it worth changing i my code.. Perhaps i wil leave the datamapper lib intact and create an extend of it. I can overrule the error function there!


DataMapper 1.6.0 - El Forum - 03-02-2009

[eluser]OverZealous[/eluser]
That's probably best for the short term. I wonder if it makes more sense to stop the error checks after the first error (which would mean adding a 'break;' after an error has occurred. (If someone needs to have multiple checks, they could combine them into one custom error.)

Also, it would prevent the errors from checking after a known problem occurs, and also prevent potential PHP errors (ie: a custom error expects a non-empty value, but gets called even after 'required').

Any thoughts?