Welcome Guest, Not a member yet? Register   Sign In
DataMapper ORM v1.8.2

[eluser]insert_hilarity_here[/eluser]
I do not see the difference, for example

Code:
$item = "users.updated_on >=";

print "CI 2.1.1\n";
preg_match('/^([^\s]+) (AS )*(.+)$/i', $item, $matches);
print_r($matches);


print "WanWizard\n";
preg_match('/^([^\s]+) (AS )*([^\s]+)$/i', $item, $matches);
print_r($matches);

both return the same results
Code:
CI 2.1.1
Array
(
    [0] => users.updated_on >=
    [1] => users.updated_on
    [2] =>
    [3] => >=
)
WanWizard
Array
(
    [0] => users.updated_on >=
    [1] => users.updated_on
    [2] =>
    [3] => >=
)

and both will escape $matches[3] which is >=

The fix they have put in is just to revert the change to the way it previously was: https://github.com/EllisLab/CodeIgniter/...driver.php

This means aliases do not get escaped, but to escape them I think they would have to define in $_reserved_identifiers what not to escape. Managing that array would be problematic so I do not think its a good solution.

[eluser]WanWizard[/eluser]
Absolutely right. Which against shows that quick fixes are seldom fixes... Wink

[eluser]coldscooter[/eluser]
Part of the DataMapper installation includes a folder that goes in the application directory called "DataMapper". This includes class files such array.php, csv.php, etc.

When are these files used, and how do I use these classes?

If i remove this folder all my Datamapper code still works.

What would be the syntax, for example, of using the
Code:
DMZ_Array::to_array()
on a DataMapper object?

Thanks in advance.

[eluser]insert_hilarity_here[/eluser]
Check out http://datamapper.wanwizard.eu/pages/extensions.html and http://datamapper.wanwizard.eu/pages/extlist.html

For the array extension in application/config/datamapper.php you would have
Code:
$config['extensions'] = array('array');

[eluser]JamieBarton[/eluser]
[quote author="WanWizard" date="1339429478"]What you basically want is a many-to-many self referencing relationship for the users model.

This means you need a users_users relationship table which contains the user_id and friend_id columns.

You then define the model like so:
Code:
class User extends DataMapper {
    $has_many = array(
        'friend' => array(
            'class' => 'user',
            'other_field' => 'user',
        ),
        'user' => array(
            'other_field' => 'friend',
        )
    );
}

You can then do
Code:
// fetch a user (with id = 1)
$user = new User(1);

// fetch this users friends
$user->friend->get();

// who are your friends friends?
foreach ($user->friend as $f)
{
    $f->friend->get();
}

// who also has your friends?
// who are your friends friends?
foreach ($user->friend as $f)
{
    $f->user->get();
}
[/quote]


Great.

With this however, how easy would it be to add in the 'approved' by column.

Would I need to have the following..

user_id / friend_id
1 / 2
2/ 1

Two lines for both to be each others friends. That is how I have it setup right now in my friends table.


Regards

[eluser]WanWizard[/eluser]
In my previous example I has indicated the many-to-many needed a relationship table, which indeed contains the columns user_id and friend_id.

You can add extra columns to this table, and use where_join_field() to query the relation based on the contents of the 'approved' column.

[eluser]shenanigans01[/eluser]
Heya WanWizard,

I'm interested to know if you've seen / checked out the post listed here: Basic Login / Auth System

I'm sure your very busy but I think a basic auth system like the one provided at the link above is a nice idea to have built around datamapper with the common features of forgot pass, activation etc... I'm curious to know if the code provided is pretty solid in terms of performance / security or if there's more efficient ways ... Thanks!! Smile

[eluser]WanWizard[/eluser]
I've seen the post, but haven't had the time to look at it in detail.

As to security, the example application is just that, it's been around since DMZ days, and I don't think anyone has had a look at the security side of things.

It's security is based on the assumption that the onderlying framework is secure. I think the forms could use CSRF protection which the example doesn't use.

Usually the most dangerous bit is the remember-me code, if you can copy the cookie to another PC and get in, you have a serious security issue. So you should definitely look into that.

[eluser]pyweb1[/eluser]
hi, I am trying to make a simple modular application, say a news_ribbon, called news_strip,
it get all the news information in a news_strips database table and show it. the goal of this is to make a default codeigniter + hmvc + datamapper working installation rar for futur project.

anyway, i read a lot of information about hmvc and datamapper being natively compatible like in the datamapper userguide FAQ. Sadly, i can't get datamapper to load my models if they are in any modules/modules/models folder.

Quote:Fatal error: Class 'News_strip' not found in H:\xampp\htdocs\Dropbox\Web\news_strip_module\application\modules\news_strip\controllers\news.php on line 6

Here is my setup, i have the last version of HMVC and the last version of DataMapper installed on the last stable version of CI, (all the files, and bootstrap, and I autoload database and datamapper in application/config/autoload.php)

here is my module:
Code:
// application/modules/news_strip/controllers/news.php

class News extends CI_Controller{

function index(){
  $n = new News_strip();

}
}
Code:
// application/modules/news_strip/models/news_strip.php

class News_strip extends DataMapper {

}

is there something special i need to do to get it working?

[eluser]WanWizard[/eluser]
Datamapper will scan APPPATH, all package paths, and all defined paths (both in the global Datamapper config and in the model) for a folder called 'models', and in there for the model to load (including any subfolders).

When you load a module in MX, it will add the module path to the loader's package paths, which means that Datamapper will be able to load modules from that module.

Note that this only works once the module has been loaded, Datamapper doesn't have a magical way to know it has to search through modules too.

You can manually add a module path using $this->load->_add_module_paths($modulepath), once MX is loaded.




Theme © iAndrew 2016 - Forum software by © MyBB