Welcome Guest, Not a member yet? Register   Sign In
Cannot modify header information - Codeigniter / DataMapper OverZealous Edition

[eluser]Watermark Studios[/eluser]
Just so everyone knows...yes, I have checked other threads here and other places online for help.

I'm getting the below error:

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at E:\inetpub\vhosts\...\httpdocs\main\application\controllers\test.php:19)

Filename: codeigniter/Common.php

Line Number: 356
A Database Error Occurred

Unable to connect to your database server using the provided settings.

Let me set the stage here a bit. I have a working site that uses the CI/DMZ config to access the database. Every other model is working fine. I set up a test controller so I could investigate. Below is the method that is returning the error:

15 function country(){
16   $location = new Location();
17   $location->where('country','US')->where('type','MAI')->get();
18   $count = $location->where('country','US')->where('type','MAI')->count();
19   echo $count . "<br/>";
20   foreach ($location->all as $loc) {
21     $loc->user->get();
22     echo $loc->user->lastname . "<br/>";
23   }
24 }

The Count variable is correctly returning the number of results. The first 30 last names are also returned, so it is working initially. The rest of the results are omitted and the error kicks in.

Any thoughts?

does it work correctly without the echo's in lines 19 and 22? If not, what is the error reported then?

[eluser]Watermark Studios[/eluser]
If I comment out both lines 19 and 22, then I get an error 500. Database resource can not be found. If I uncomment, I at least get some response, but then it breaks shortly into it and throws the PHP errors.

[eluser]Watermark Studios[/eluser]
I tracked down the error.

Error: Unknown column 'locations.country' in 'where clause'

Unfortunately, there is a country column in the locations table. My full query looks like this:

SELECT `users`.* FROM (`users`) WHERE `locations`.`country` = 'US' AND `type` = 'MAI' ORDER BY `users`.`lastname` asc LIMIT 50

Any thoughts?

yeah, I have a thought. You aren't joining the locations table to your query. You are trying to base a where clause on a table not in the query.

[eluser]Watermark Studios[/eluser]
I was just thinking the same thing. But I'm using DMZ ORM to manage the transaction. It shouldn't use a query like that. What I write is:

$user_info = new User();
foreach($user_info as $user){
  echo $user->fullname . "<br/>";

then for some reason it's translating it to what I put above. DMZ works great for all of the other transactions. As a matter of fact, this is the only transaction I have any problems with and I can't figure it out for the life of me.

I've never used DMZ before, but have you specified (or even do you have to specify) the relationship in between the two models in the the models? Do you have to set a $has_one = 'location' in the users model and a $has_many = 'users' in the location model or something?

If you do, have these been set properly?

[eluser]Watermark Studios[/eluser]
Yep...both are set. There seems to be some glitch I'm going to have to work around.

Theme © iAndrew 2016 - Forum software by © MyBB