CodeIgniter Forums
DMZ 1.7.1 (DataMapper OverZealous Edition) - 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: DMZ 1.7.1 (DataMapper OverZealous Edition) (/showthread.php?tid=28550)



DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 07-28-2010

[eluser]OverZealous[/eluser]
@Jfly
That's not a mistake. That's the table alias. It does it for all joins, because they are sometimes different, and it has never given me a problem.


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 07-28-2010

[eluser]Jfly[/eluser]
Thanks, I just found out that the error was because my table name was in MySQL reserved words.


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 07-29-2010

[eluser]Jfly[/eluser]
[quote author="OverZealous" date="1280334926"]@Jfly
That's not a mistake. That's the table alias. It does it for all joins, because they are sometimes different, and it has never given me a problem.[/quote]

I just found out that the problem is caused by my table name, which is conflicted with mysql reserved names. However, I never have this kind of problem, because I use prefix for table names. I think the problem here is that DMZ removes prefix in the table alias.


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 07-31-2010

[eluser]dejavu[/eluser]
I've got a bit of oddness happening in DataMapper DMZ. I'm somehow triggering an error:

In line 603
Code:
// Get and store the table's field names and meta data
$fields = $this->db->field_data($this->table);
I get the error:
Quote:Fatal error: Call to a member function field_data() on a non-object in C:\Users....
But if I add a call to get_class_methods($this->db) just before this line, it works:
Code:
// Get and store the table's field names and meta data
echo "<pre>"; print_r(get_class_methods($this->db)); echo "</pre>";
$fields = $this->db->field_data($this->table);
Apparently the get_class_methods() call somehow triggers an autoload that wouldn't otherwise be called??? Any suggestions what I can look at to fix this without patching DataMapper?


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 07-31-2010

[eluser]OverZealous[/eluser]
@dejavu
That's not a DMZ issue. The DB object is created on-the-fly using a magic __get method, but all of the internal methods rely on that magic method. There's no reason you should get that error unless you are doing something wacky. Wink


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 07-31-2010

[eluser]dejavu[/eluser]
[quote author="OverZealous" date="1280627627"]@dejavu
That's not a DMZ issue. The DB object is created on-the-fly using a magic __get method, but all of the internal methods rely on that magic method. There's no reason you should get that error unless you are doing something wacky. Wink[/quote]

LOL... I was just about to post nevermind, I think I know the problem. I am using Modular Extensions - which qualifies as wacky, I think.

I added something to add the ME directories to the autoload method, but apparently the $this->db is never set up properly. I'll figure it out. Thanks.


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 08-01-2010

[eluser]RaZoR LeGaCy[/eluser]
I need to make a simple CRUD with Datamapper but I am lost. Does anyone have a simple CRUD app that we can download or view online.

Read the user guide and trying to just echo out data from table.


Code:
class Movie extends DataMapper {

  var $table = 'encyclopedia_text';

  function get_movies(){
    $u = new Movie();
    return $u->get();
  }

Code:
class Movies extends Controller {

  function movies() {
    parent::Controller();
    $this->load->library('datamapper');
  }

  function index() {
    $d = new Movie();
    echo $d->get();
  }



DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 08-01-2010

[eluser]BaRzO[/eluser]
@RaZoR LeGaCy you have to read user guide [url =http://www.overzealous.com/dmz/]DMZ[/url]


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 08-01-2010

[eluser]RaZoR LeGaCy[/eluser]
I did. I released my error was that I was naming the model file "name_model" and I just needed to name the model "name". I thought DMZ could just take the table and spit out a form like CI scaffolding. I thought that it would read that the field type was text for example and create a textarea automatically. Is there a way to do this?

I now have for Controller->index()
Code:
$u = new Movies();
    $movies = $u->get_movies();

    $u->load_extension('htmlform');

    $form_fields = array(
         'tid',
         'title',
         'text' => 'textarea',
         'eid',
         'img',
         'counter',
     );

    echo $u->render_form($form_fields, 'savehere');

Model
Code:
class Movies extends DataMapper {

  var $table = 'nuke_encyclopedia_text';

  function get_movies(){
    return $this->get_by_eid(3)->limit(5)->get();
  }
}

Anyone know of a simple CRUD app using DMZ only that would show the correct way? I am talking about a Create Row, Review Data, Update Row, Delete Row Controller.

DMZ looks extremely powerful. I did a print_r() on $u and it returned all settings in the config, database, helpers loaded, models loaded etc. Print_r() on $u crashed firefox by the way LoL


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 08-01-2010

[eluser]BaRzO[/eluser]
Maybe you can combine DMZ and [url =http://ellislab.com/forums/viewthread/107861/]FormGenLib[/url]