Welcome Guest, Not a member yet? Register   Sign In
[Deprecated] DMZ 1.6.2 (DataMapper OverZealous Edition)

[eluser]OverZealous[/eluser]
This has nothing to do with PHP

This is basic Object Oriented Programming stuff. You are trying access the $this variable — a variable that refers to an instantiated object — but in a static context.

The only things you can refer to in a static context are global methods, static properties, and other static methods.

[eluser]cahva[/eluser]
I have solved the lang problem by creating a new method which sets the validation:
Code:
class Customer Extends DataMapper {
    var $table = 'customers';
    var $has_one = array('group');
    var $has_many = array('addressbook');
    var $validation = array();

    function __construct()
    {
        parent::__construct();
        $this->_set_validation();
    }

    function _set_validation()
    {
        $this->validation = array(
            'name' => array(
                'label' => lang('account.name'),
                'rules' => array('required', 'trim', 'max_lenght' => 255)
            ),
            'email' => array(
                'label' => lang('account.email'),
                'rules' => array('required', 'trim', 'unique', 'max_length' => 255, 'valid_email')
            ),
....
....

[eluser]Muser[/eluser]
I don't know if it is a bug or I have missed a step... but I've upgraded from 1.4.0 to 1.6.1 and when I've tried to load the page I have got this error:

Fatal error: Call to a member function load() on a non-object in C:\webs\xampp\htdocs\grera\application\libraries\datamapper.php on line 615

I have checked the line 615:

Code:
if($name == 'form_validation')
        {
            $CI =& get_instance();
            if( ! isset($CI->form_validation))
            {
                $CI->load->library('form_validation');
            }
            $this->form_validation = $CI->form_validation;
            $this->lang->load('form_validation');
            return $this->form_validation;
        }

Maybe it should be this?

Code:
if($name == 'form_validation')
        {
            $CI =& get_instance();
            if( ! isset($CI->form_validation))
            {
                $CI->load->library('form_validation');
            }
            $this->form_validation = $CI->form_validation;
            [b]$CI->lang->load('form_validation');[/b]
            return $this->form_validation;
        }

[eluser]OverZealous[/eluser]
@Muser
The only way this could happen is if you are trying to access $this->form_validation before calling parent::__construct() in your model's constructor.

This is not a problem with DMZ.

[eluser]Muser[/eluser]
@tdktank59: I have corrected some orthography and gramatical errors on your spanish lang file.

Also, I have posted a catalan lang file.

[eluser]OverZealous[/eluser]
Thanks for the language files, Muser and tdktank59. I've added them to the distribution.

If anyone else out there would like to provide localized error messages, I would be very appreciative!

Out of curiosity, what naming structure would you prefer for the language folders:

1) Use the English names for the languages:
Code:
catalan/
english/
spanish/

2) Use the native names for the languages (in unaccented ASCII characters):
Code:
catala/
english/
espanol/

3) Use the ISO-639-1 2-letter codes:
Code:
ca/
english/ (for CI compatibility)
es/

Personally, I prefer #3 whenever possible. In fact, if I ever localize my application, I would be tempted to use an RFC 5646 structure like this:
Code:
ca/
en/
en-US/
en-GB/
es/
es-ES/
es-MX/
...

[eluser]chadbob[/eluser]
get isn't working for me when inside of a helper...I'm stumped!


The rest of my CI/DMZ app works perfectly fine, with get statements inside of controllers, however I have something that will be used everywhere, so I want to put it into a custom helper.


I've made it as simple as I can, and the problem still happens:

Code:
$p = new Report();
$p->get();
return count($p->get());

In a helper, that always returns "1". Which is wrong.

However, those three lines in a controller always return the accurate count...I'm not sure what's going on. Is there something with the helper system that prevents DMZ from working correctly in this scenario?

[eluser]OverZealous[/eluser]
@chadbob

I doubt those exact lines work differently in your controller.

There is nothing wrong with what it is returning. Because you are calling get a second time, there is only one item in the array.

Your code should look like this:
Code:
$p = new Report();
$p->get();
return count($p->all);

EDIT: Made a slight change to count ->all explicitly.

[eluser]chadbob[/eluser]
[quote author="OverZealous" date="1261565899"]@chadbob

I doubt those exact lines work differently in your controller.

There is nothing wrong with what it is returning. Because you are calling get a second time, there is only one item in the array.

Your code should look like this:
Code:
$p = new Report();
$p->get();
return count($p->all);

EDIT: Made a slight change to count ->all explicitly.[/quote]



Sorry, that was a typo in my post, I should have copied/pasted.

My code is indeed:

Code:
$p = new Report();
$p->get();
return count($p->all);


It will only give me the first report by date (this auto sort is spec'd in the model).

However in a controller, it gives me all of them.


I've even made a new helper and a new controller just to see, and with different names for the objects. Same deal.

Another thing I tried is that a get where works in the helper:

ex:

Code:
$p->where('id', 4)->get();

I can change that number, and I always get the correct report. But the minute a get should return more than one, and it's in a helper, it just spits out the first report in line.

[eluser]OverZealous[/eluser]
Make 100% sure you are doing this: count($p->all) and not this: count($p). I just tested it to be sure, and the latter always returns 1.

I've got helpers all over, and have never seen anything like this. It just doesn't make sense, since $p->all is a normal PHP array, and count is an internal PHP function.

Is the Datamapper library getting loaded correctly before it is used in your helper? Are you sure that $p is a valid object?

Again, I just tested it, using almost exactly the same code. Works perfectly for me.




Theme © iAndrew 2016 - Forum software by © MyBB