0

I've tried stensi but I see it has some mistakes and unexpected output as mentioned in the user guide.

For example, when trying to delete a record it gives this error:

$p=new Per();
$p->where('id',1)->get();
$p->delete();

with an error message of:

 undefined index id

when

  echo $p->UserName;

outputs:

   mhmd

and WanWizard has also this error:

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

<p>Severity: Warning</p>
<p>Message:  array_key_exists() expects parameter 2 to be array, boolean given</p>
<p>Filename: libraries/datamapper.php</p>
<p>Line Number: 399</p>

How can I overcome these errors or what can I do to make it work properly?

chembrad
  • 887
  • 3
  • 19
  • 33

5 Answers5

0

I've changed the two lines of code at ../libraries/datamapper.php line 399 (WanWizard version):

$d = array($this->config->item('datamapper'));
DataMapper::$config = $d;

and the error message disappeared.

If anyone has tried DataMapper and has a better suggestion, please let us know.

Asherah
  • 18,948
  • 5
  • 53
  • 72
0

just found out this error can occur if you autoload the datamapper config file

Johnny Tops
  • 610
  • 1
  • 6
  • 10
0

Stensi's original version hasn't been maintained since 2007, and only supports CI 1.4. Not really an option anymore these days. It was forked by Overzealous in 2008, and I took over maintenance of that fork in 2010.

WanWizard
  • 2,574
  • 15
  • 13
0

I fixed this (in the CI spark version) by moving the config file from the sparks directory to the /application/config directory.

0

There's something strange happening in CI v2.1.4 where

$this->config->load('datamapper', TRUE, TRUE);

on line 391 of application/libraries/datamapper.php in Datamapper-ORM v1.8.2.1 isn't "namespacing" the config correctly. If you do

print_r ($this->config); die;

just after line 391, you'll see all of the config values are in the general CodeIgniter "namespace" inside the loaded config array. The least intrusive way to get around this is to manually namespace your application/config/datamapper.php file yourself, by changing all the references from

$config['prefix'] = '';
$config['join_prefix'] = '';
...

to

$config['datamapper']['prefix'] = '';
$config['datamapper']['join_prefix'] = '';
...

That's how I got around it. Though @Mhmdgomma's fix does work, I prefer not to hack the core of the system when there is a simpler solution available. Someone should probably get the maintainers to fix this, but I'm not sure where the issue lies. It looks more like it's a CI issue, rather than DM.

Curt
  • 1