upgrade from 1.4.x to 2.1.2 datamapper installation. |
[eluser]Grego606[/eluser]
I thought I had followed the instructions closely for installing datamaper: http://datamapper.wanwizard.eu/pages/installation.html But I get this error: Fatal error: Class 'bands' not found in /home/opendoor/public_html/classicgaragerock.com/application/libraries/datamapper.php on line 1072 Code: line 1072 $this->{$name} = new $class(); // bands is one of the tables that gets converted in datamapper.
[eluser]WanWizard[/eluser]
Datamapper doesn't do anything with tables, it deals with models. So that should autoload /application/models/bands.php, which should contain a class called "Bands" which must extend Datamapper.
[eluser]Grego606[/eluser]
[quote author="WanWizard" date="1349851023"]Datamapper doesn't do anything with tables, it deals with models. So that should autoload /application/models/bands.php, which should contain a class called "Bands" which must extend Datamapper.[/quote] You are quite correct. Forgive my inaccuracy. Is this how my models should look? Code: <?php
[eluser]WanWizard[/eluser]
No. As shown here and on the next page, you would normally use Code: var $has_many = array('song', 'file'); If your models are defined non-standard, or you want the relation name to be different from the model name, you need the advanced relationship notation, as documented here.
[eluser]WanWizard[/eluser]
Also, What is the intention of this method: Code: function Band($condition = array()) If it's meant to be a constructor, use __construct() instead. You can't call parent:atamapper, you have to call parent::__construct(), as documented here. And the constructor parameter is a numeric id, not an array...
[eluser]Grego606[/eluser]
Thank you that helps a lot. My new error code is: Fatal error: Class 'labels' not found in /home/opendoor/public_html/classicgaragerock.com/application/libraries/datamapper.php on line 1072 The only place I can find a reference to "labels" is in a file called "common_model.php" This file joins various tables. Is it coded correctly for Datamapper? [code class Common_model extends DataMapper { . // let me know if you need to see this code . //------- CUSTOM --------// function get_bands($iLimit = null, $iOffset = 0) { $oData = new stdClass; $oData->total = $this->db->count_all_results('bands'); $this->db->select('bands.*, labels.name as label'); $this->db->from('bands'); $this->db->join('bands_labels', 'bands.id = bands_labels.band_id', 'left'); $this->db->join('labels', 'labels.id = bands_labels.label_id', 'left'); if (! is_null($iLimit)) $this->db->limit($iLimit, $iOffset); $this->db->order_by('labels.name asc, bands.sort asc'); if ($query = $this->db->get()) { $oData->result = $query->result(); $this->db->flush_cache(); return $oData; } return false; } function get_songs($iLimit = null, $iOffset = 0) { $oData = new stdClass; $oData->total = $this->db->count_all_results('songs'); $this->db->select('songs.*, bands.name as band, labels.name as label'); $this->db->from('songs'); $this->db->join('bands_songs', 'songs.id = bands_songs.song_id', 'left'); $this->db->join('bands', 'bands.id = bands_songs.band_id', 'left'); $this->db->join('labels_songs', 'songs.id = labels_songs.song_id', 'left'); $this->db->join('labels', 'labels.id = labels_songs.label_id', 'left'); if (! is_null($iLimit)) $this->db->limit($iLimit, $iOffset); $this->db->order_by('labels.name asc, bands.sort asc, songs.sort asc'); if ($query = $this->db->get()) { $oData->result = $query->result(); $this->db->flush_cache(); return $oData; } return false; } }[/code] Thank you so much for looking at this.
[eluser]WanWizard[/eluser]
wasn't labels one of your relations? And why do you have a datamapper model that does db calls? If your model doesn't implement Datamapper, you better extend CI_Model instead, it will save you some memory and CPU.
[eluser]Grego606[/eluser]
I inherited this site. It was working fine till my isp decided to update php to the latest version, and my side broke. I am attempting to upgrade CI to the latest version. I saw DM files in my forensic reconstruction of the site. There were calls for it in the legacy site...
[eluser]WanWizard[/eluser]
If this was a CI 1.4 site, chances are it is even using Stensi's Datamapper. Which has been dead for several years, and mine isn't really compatible anymore (it's around since early 2009).
|
Welcome Guest, Not a member yet? Register Sign In |