Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not get field_data by $query->field_data(); #1619

Closed
sdhiraj opened this issue Jul 14, 2012 · 5 comments
Closed

Can not get field_data by $query->field_data(); #1619

sdhiraj opened this issue Jul 14, 2012 · 5 comments

Comments

@sdhiraj
Copy link

sdhiraj commented Jul 14, 2012

$query = $this->db->query("YOUR QUERY");
$fields = $query->field_data();

In Codeigniter 2.1.2 When executing this type of query it gives following errors
(it works fine in 2.1.0)

A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$Type

Filename: mysql/mysql_result.php

Line Number: 89
A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$Field

Filename: mysql/mysql_result.php

Line Number: 95
A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$Default

Filename: mysql/mysql_result.php

Line Number: 97
A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$Key

Filename: mysql/mysql_result.php

Line Number: 99

@appleboy
Copy link
Contributor

You must set one parameter for table name.

$fields = $query->field_data('test');

@ghost
Copy link

ghost commented Jul 19, 2012

Use build in CI function to get field names. Why need to write SQL.

$fields = $this->db->list_fields('table_name');

@hipsterjazzbo
Copy link

This is still quite obviously and thoroughly broken. In 2.1.2 field_data() is using mysqli_fetch_object, which seems completely wrong as that method returns the row itself, not data about it. Not sure of when this could ever work.

There are several related issues that have been closed (#1111, #785, #1101), but the attached commits don't seem to work - they fix the field_data() call on a query result object, but break $this->db->field_data() in the sense that it now returns different results (i.e. fields types are strings instead of numerical).

@appleboy You only need to pass in the table name when calling $this->db->field_data($table). When calling field_data() on a query result object, you don't need the table name.

@goserverside Again, @sdhiraj is talking specifically about calling field_data() on a query result object.

This is stinging me hard at the moment, so just wanted to add some more detail and make sure this issue doesn't get ignored. If I manage to fix it before I run out of time and have to abandon the upgrade, I'll submit a pull request.

@hipsterjazzbo
Copy link

I should have said, I can see that this SEEMS to be fixed in 3.0-dev, although I haven't tested.

@narfbg
Copy link
Contributor

narfbg commented Nov 15, 2012

It is indeed fixed in develop.

@narfbg narfbg closed this as completed Nov 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants