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

[eluser]q.Nghia[/eluser]
[quote author="OverZealous" date="1258945279"]@q.Nghia

The only solution is to upgrade your server's version of PHP, or modify the htmlform extension. As it says in the docs, some extensions require a newer version of PHP.

(Win NT? Yuck! Smile )[/quote]

Yes, I will ask the host to upgrade PHP version, many thanks Big Grin

[eluser]Benedikt[/eluser]
Hi,

Im still using 1.5.4 that's why I ask my question here:

I have a controller where I instantiate my DataMapper model:
Code:
/* Bike-Object */
        $b = new Bike();
        $b->where('key', $key);
        $b->where('color', 'red');
        $b->get();

The model looks like this:
Code:
class Bike extends DataMapper {

    var $table = 'cti_bikes';

    public function Bike () {
      parent::DataMapper();
    }
}

When I run
Code:
$b->count();
it return 2 even there is only 1 database entry.

When I run
Code:
$b->check_last_query();
the database query is shown twice.

It seems I am doing something basically wrong as it seems to affect all my datamapper models. The Constructor is always called twice.

Any idea what could be wrong?

Thanks for help.

[eluser]OverZealous[/eluser]
If you want the number of items returned from a query, just use the PHP methods:
Code:
count($b->all)

Calling get clears the current query. count attempts to run another query, but because you are calling without any where statements, it simply returns the number of rows in the table.

[eluser]Benedikt[/eluser]
Thanks for your reply, makes sense.

But why is it called twice? This seems to another mistake I am making.

Any idea what could be wrong here?

Thanks for your help!

Another thing is when I run the query above, if I run $b->exists() after get() it says FALSE. I thought it should work like that? Or does it only work after a "get_by_id"?

[eluser]Benedikt[/eluser]
Just by <code>new Bike;</code> it already runs twice <code>SELECT * FROM `cti_bikes` LIMIT 1</code>

Is that supposed to be like that?

[eluser]OverZealous[/eluser]
That's not a COUNT query. It doesn't have COUNT in it.

See here for more information about that query. (The Google search on the docs turns it up, just so you know. I know it isn't in the FAQs, however.)

[eluser]Benedikt[/eluser]
Ok, that solved the "Limit 1" messages, thanks. I didnt find this as I was not thinking about production cache yet. Thanks.

So it seems I have a general problem about querries. Now it shows me the session-querries (not related to DMZ) to be run twice.

I need to check if "check_last_query" might be buggy or what is going wrong in general.

[eluser]OverZealous[/eluser]
check_last_query auto outputs to the browser (and still returns the result). Maybe that's your problem? Check the docs for check_last_query. It is not buggy.

Also, if you are debugging, I highly recommend using $this->output->enable_profiler(TRUE); whenever possible. It provides more detail.

[eluser]Benedikt[/eluser]
Argh, Im hunting ghosts.

Thanks for pointing me to this. Seems it was just too late last night.

Thanks and sorry for being blind.

[eluser]GregX999[/eluser]
Hey, is there a way to write a trigger? (I think it's called a trigger.) I want to put a method in a model that gets called when an object of that type gets deleted. It's an "Image" model, and if an Image object gets deleted, I want the model to delete all the appropriate image files.

Greg




Theme © iAndrew 2016 - Forum software by © MyBB