Welcome Guest, Not a member yet? Register   Sign In
DMZ 1.7.1 (DataMapper OverZealous Edition)

[eluser]lexusgs430[/eluser]
Hi,

Im trying to use query string + pagination and I cant seem to get it working quite right. It is returning the number of results correctly and what not, but actually navigating to the pages (ie page 2) within the results, I cannot figure out how. Ive been trying to figure out the right way to access the pages but no luck.

Can anyone tell me whether its possible to use querystrings + pagination or if its just not going to work?

For example -

I have a controller called search and a function called query

the url of results looks like this- search/query?search=mens+watch

Which is working, but accessing the pages of the result isnt.

[eluser]OverZealous[/eluser]
@lexusgs430
Are you referring to the DMZ's pagination code? DMZ's code doesn't handle rendering the pagination. It merely handles getting pages of results, and gives you a ton of variables to help.

If you are referring to the CodeIgniter library, that is not part of DMZ, and should be asked elsewhere.

(In either case, CodeIgniter doesn't support query strings by default. You have to hack the Input library to get them working.)

[eluser]NachoF[/eluser]
Thank you Phil, I have finally figured it out using always_validate and a custom zero_on_empty function

I have now a question regarding the unique_pair validation method.. how can I make it work with relations?

Heres the model structure, a project has many stages, and each stage has a year field.. so basically, a project shouldnt have two stages with the same year value...

On my stage model I have
Code:
var $validation = array(
        'year' => array(
            'label' => 'Year',
            'rules' => array('required', 'trim', 'numeric','unique_pair' => 'project_id')
            ),

Is that the right approach or should I somehow do something that doesnt involve the project_id but the project object itself?? please help.

[eluser]OverZealous[/eluser]
@NachoF
You could try this, but this should be enforced through business logic, not through field rules. That's not what they are meant for.

[eluser]NachoF[/eluser]
[quote author="OverZealous" date="1278012468"][b]@NachoF[b]
You could try this, but this should be enforced through business logic, not through field rules. That's not what they are meant for.[/quote]

well, I tried it but after doing
Code:
$stage->save($project)
it doesnt seem to valiadate it.... just to check I changed the unique_pair value to another value in the stage table and that works so Im clueles on how to get it done?? maybe with a related validation rule?

[eluser]OverZealous[/eluser]
@NachoF
You just have to write some code! Like I said, not through [validation] rules.

[eluser]NachoF[/eluser]
[quote author="OverZealous" date="1278019935"]@NachoF
You just have to write some code! Like I said, not through [validation] rules.[/quote]

its not about not wanting to write code... its about doing it the most elegant way....Checking that the project doesnt already have a stage with that year value is trivial to write.. I just dont think its something that belongs in my controller.... I dont understand why you say its not a validation issue when you defined the function unique_pair

[eluser]OverZealous[/eluser]
@NachoF

I didn't define the function - it's from DataMapper. And it's designed to work with normal fields. It's designed specifically to mirror the functionality of a compound primary key.

The reason field validation rules won't work against relationships is that the relationships aren't set until after the object has been saved. You might be able to make a related validation rule work, but I don't usually do much with those.

The reason I think this absolutely belongs in a controller is this is a business logic function. This is something that needs to be enforced through application logic. I don't understand why it would ever be possible for the user to pick an invalid combination in this instance. In general, it's more a matter of opinion, and design choice.

[eluser]Quaotloa[/eluser]
Hi.
I tried to use datamapper, but I only get this error, when i try to create models..
Fatal error: Class 'DataMapper' not found in /Applications/MAMP/www/application/models/_template.php on line 22

If i try to remove _template.php file, I get no errors, until i create a new model, where I inherit from DataMapper.. Then i get the same error, with a reference to another file of course..


Why do this error occour? Eclipse do find DataMapper, so the file is there, and I have followed the installation guide..

[eluser]happydude[/eluser]
I just set up my datamapper models and when trying to initiate any one of them in my controller (e.g. $request = new Request() ), I get this error message:

Fatal error: Cannot access empty property in C:\Users\Scofield\Documents\My Dropbox\Dev\xampp\htdocs\dma\system\application\libraries\datamapper.php on line 2352

Any help rendered will be greatly appreciated




Theme © iAndrew 2016 - Forum software by © MyBB