Welcome Guest, Not a member yet? Register   Sign In
DataMapper ORM v1.8.0
#71

[eluser]Basketcasesoftware[/eluser]
Tried the above (or close enough to it) on my already freshly installed CI. Failed.
Trying and even fresher install with the exact same stuff you posted, WanWizard. The only thing I don't have is the code you used for the model.
Edit: Ok. This doesn't look good!
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Welcome::$db

Filename: libraries/datamapper.php

Line Number: 1042
A PHP Error was encountered

Severity: Warning

Message: register_shutdown_function() [function.register-shutdown-function]: Invalid shutdown callback 'Array' passed

Filename: libraries/datamapper.php

Line Number: 1042

Fatal error: Call to undefined method stdClass::_reset_select() in C:\xampp\htdocs\freshinstall\application\libraries\datamapper.php on line 1047
#72

[eluser]WanWizard[/eluser]
Looks like the database is not loaded either...
#73

[eluser]DominixZ[/eluser]
Code:
A Database Error Occurred
Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'references ON `users`.`id` = `references`.`user_id` WHERE `references`.`id` = 12' at line 3

SELECT `users`.* FROM (`users`) LEFT OUTER JOIN `references` references ON `users`.`id` = `references`.`user_id` WHERE `references`.`id` = 12

I got this error from i use $reference->user->id;
but if i use $user->reference->id it works fine

The SQL that generate has "references" twice on join
#74

[eluser]Basketcasesoftware[/eluser]
[quote author="WanWizard" date="1297561476"]Looks like the database is not loaded either...[/quote]
I thought that might be the issue. I was hoping to create a generic test model with out having to create a test db. Got that error message and created one just for the purpose of testing.

Same error. I'm going to switch browsers and see if it's a cache issue.

database.php file:
Code:
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'ritg1967';
$db['default']['database'] = 'test';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

database:
Code:
-- phpMyAdmin SQL Dump
-- version 3.2.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Feb 12, 2011 at 02:02 PM
-- Server version: 5.1.41
-- PHP Version: 5.3.1

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `test`
--

-- --------------------------------------------------------

--
-- Table structure for table `dmobjs`
--
-- Creation: Feb 12, 2011 at 01:47 PM
--

DROP TABLE IF EXISTS `dmobjs`;
CREATE TABLE IF NOT EXISTS `dmobjs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `test` text COLLATE utf8_bin,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

--
-- Dumping data for table `dmobjs`
--


/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

model: dmobj.php
Code:
<?php

class Dmobj extends DataMapper
{
    var $has_one = array();
    var $has_many = array();

    function __construct($id = NULL)
    {
        parent::__construct($id);
    }    
}

/* End of file dmobj.php */
/* Location: ./application/models/dmobj.php */
#75

[eluser]WanWizard[/eluser]
What do your database tables look like? And your models? And the code that generates this error?

$reference->user->id doesn't generate any SQL, it just returns the id (if any) from the current user object.
#76

[eluser]Basketcasesoftware[/eluser]
You must have caught me in the middle of that last reply. It's all there. I'm switching from FF to IE real quick. Seeing if there is just a cache problem.
#77

[eluser]WanWizard[/eluser]
@Basketcasesoftware,

Did you load the database ( either using autoload, or via $this->load->database() ) BEFORE you load the datamapper library?
#78

[eluser]Basketcasesoftware[/eluser]
[quote author="WanWizard" date="1297563458"]@Basketcasesoftware,

Did you load the database ( either using autoload, or via $this->load->database() ) BEFORE you load the datamapper library?[/quote]
Doh! I was going by the short version of the DataMapper installation instruction. Keep forgetting that CI is a "lazy loader" Smile

I'm adding the suggested auto load line from the Guide. Let's see if it works this time...

Oh yeah! That was it. Boy I have egg on my face! Thanks. RTFM.
#79

[eluser]WanWizard[/eluser]
Next version will check if the database library is loaded, and exists with an error message if not. That will save others having a similar struggle some time... Wink
#80

[eluser]Basketcasesoftware[/eluser]
How about being able to set it to load the database library if it isn't loaded. As an option of course. ;-P




Theme © iAndrew 2016 - Forum software by © MyBB