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 - 12-20-2008

[eluser]Emanuel01[/eluser]
Good work , thx .
I like the validation system with the rules in arrays .


DataMapper 1.6.0 - El Forum - 12-21-2008

[eluser]robertcsmith[/eluser]
Great stuff CC! This is a fantastic and elegant solution for those of us in the same boat.

Testing it now...

is get_array() on line 3498 (my personal fav).. is it needed or was it just a test?

so far this is my only thought:
[quote author="commandercool" date="1229703334"]
I'm not going to post every one of the added vars, functions and changes I made, plus this is still a work in progress, so i'll just attach the DataMapper file i've got so far and let anyone who wants to play with it, do just that.
[/quote]
when everything is ironed out perhaps consider offering this as an extended base class for DM rather than the need to replace all the code.


DataMapper 1.6.0 - El Forum - 12-28-2008

[eluser]Murodese[/eluser]
Having a problem that's more generally CI load-order related.

Auth library has a member object User (which is a DataMapper model), but is throwing "Class 'User' not found" errors when I try to instantiate it in the library's constructor. Both are being autoloaded, with Datamapper coming before Auth.

snippet;

Code:
class Auth
{
    var $user = NULL;
    function __construct()
    {
        $this->obj =& get_instance();
        $this->obj->load->library('encrypt');
        
        $this->user = new User();

        $this->_load_session();
    }



DataMapper 1.6.0 - El Forum - 12-28-2008

[eluser]robertcsmith[/eluser]
Hey CC, have you made any changes to your mod lately? Ive found an error while running validate() and get() to populate an instance of a class with $has_many classes.
Code:
A Database Error Occurred

Error Number: 1054

Unknown column '{$has_many_class}_count' in 'where clause'

Where {$has_many_class} is the the actual name of the has many class(es).

I haven't delved into debugging the error, but believe it is rooted in the _to_array() function. I thought Id check to see if you had made any upgrades before checking into it further. I can post or email more specific information if you need it too.


DataMapper 1.6.0 - El Forum - 12-29-2008

[eluser]ntheorist[/eluser]
@Robert

What were you trying to do when you got the error? can you post your controller code?
The aliasing feature works well for orderby and parsing results, but aliases can't be used in a WHERE clause, it seems.. i made a where_count function using group_by(id) and having, which seems to work, so i'll test that method out more

Ok i ported all the stuff i'm working on to a class that extends DM 1.6, and has the join stuff in it plus some new functions i'm playing with. Heh, yeah the get_array() thing is when i intend to over-ride, or just trying another name. I have a few added get_{how} methods there.

also, modified validation so you can validate and test specific fields:
Code:
$obj->validate_field($field) // validate specific field/relation
$obj->is_valid($field) // TRUE if field/relation is valid
$obj->is_valid() // TRUE if all fields/relations are valid
$obj->validate() // Validate all fields - same use as DM
been doing work with a form library for DM, so you'll see some of that in there, and some of it is probably still needed, lol

i'm thinking of changing adding a few more things, ie. to saving methods. Anyway its all in the works. Let me know what you think if you try it out.

@murodese

other than verifying all the class names are correct, and user.php exists in the models/ directory, all i can suggest now is try changing 'function __construct()' to function Classname(), not sure but maybe that's something CI specific when loading


DataMapper 1.6.0 - El Forum - 12-29-2008

[eluser]robertcsmith[/eluser]
The error I encountered seems to have occurred due to 'continue' being used outside of a loop to escape the current statements... not sure if this is correct but changing the 'continue' on line 1064 to the following seems to solve the validation problem I was having:
Code:
$this->valid_fields[] = $field;
return $this;

*Edit: I mean line 1033 - I forgot I added something when I was playing around


DataMapper 1.6.0 - El Forum - 12-30-2008

[eluser]Murodese[/eluser]
Having another issue;

Code:
$obj = new $node->type();
            print_ar($obj->get_by_id($node->id)->$parent_type->get()->_to_array());

$node->type holds the name of a model-class (this is correct).

$parent_type holds the name of the parent model (this is also correct).

However, I'm getting an object back with no data in the fields. The first object (client) exists and comes up fine, and the database has data linked correctly.

It's a self-referencing relationship though, which I assume is where it's causing trouble. I am totally at wits end with this however, it's worked properly for all other models I've been using, but it's having problems with this self-referenced one.

e; nevermind I'd forgotten to change a model variable :gonk:


DataMapper 1.6.0 - El Forum - 01-02-2009

[eluser]Dreammaker[/eluser]
@Murodese

Do you plan to share your crud generator? Or you develop this stuff for personal needs? I planed to implement DataMapper in Crud Generator for CI (http://ellislab.com/forums/viewthread/99274/) but if you'll share the code I will not do it.


DataMapper 1.6.0 - El Forum - 01-04-2009

[eluser]Murodese[/eluser]
Another note, just ran into a situation where having auto_transaction on completely stopped insert_id from working, leaving any objects with an id of 0 after saving.

@Dreammaker:

It's pretty tailored to our own system, but if I get time I'll clean it up a bit and post it.


DataMapper 1.6.0 - El Forum - 01-04-2009

[eluser]zool[/eluser]
Hi,
I don't know if it's the right place to post this issue because I don't know if it's a datamapper specific problem or a sqlite3 problem.

Btw...
I have a very simple Model
Code:
class User extends DataMapper {
    
    function User()
    {
        parent::DataMapper();
    }

}
and a very very simple controller
Code:
function index()
    {
        $u = new User();
        $u->username = 'Zool';
        if( $u->save() )
            echo "ok";
        else
            echo $u->error->string;
    }
The table users in the db has three fields (id, username, password) all mandatory (the id is autoincremental)

With the code posted above I have an error.
The page breaks on $u->save() because I don't provide all the fields required (the password). But why the code breaks without entering in the else statement. If I set also the password all is working fine.

Someone has a similar problem? Or know a possible solution about it?