Welcome Guest, Not a member yet? Register   Sign In
Active record
#1

[eluser]leon_dewey[/eluser]
I am getting some strange errors


This works
$this->read->select('*')->from($this->table)->where_in('username', $username);

This does not (i get a fatal error)
$this->read->select('*')->from($this->table)->where_in('username', $username)->limit(0,1);

This works, but i get no results
$this->read->select('*')->from($this->table)->limit(0,1)->where_in('username', $username);

Any ideas?

(I use a read database and write database thus the connection read, i have tryed with the traditional db)
#2

[eluser]xwero[/eluser]
[quote author="leon_dewey" date="1203011641"]I am getting some strange errors


This works
$this->read->select('*')->from($this->table)->where_in('username', $username);

This does not (i get a fatal error)
$this->read->select('*')->from($this->table)->where_in('username', $username)->limit(0,1);

This works, but i get no results
$this->read->select('*')->from($this->table)->limit(0,1)->where_in('username', $username);

Any ideas?

(I use a read database and write database thus the connection read, i have tryed with the traditional db)[/quote]
Strange you get results from the first statement? You haven't added the action
Code:
$this->read->from($this->table)->where_in('username', $username)->get();
$this->read->from($this->table)->where_in('username', $username)->limit(0,1)->get();
$this->read->from($this->table)->limit(0,1)->where_in('username', $username)->get();
This should do the trick. If you want to get all the fields you don't have to add the select because it's the default value.

edit : i though you were talking about the read as a database
Code:
var $read;

function model()
{
    $this->read = $this->load->database('dbname');
}

But i guess you have written your own database library, or not?
#3

[eluser]leon_dewey[/eluser]
Thanks for the fast reply,

you are right with regards to the DB
Code:
$this->read = $this->load->database('dbname');

I tryed
Code:
$query = $this->read->from($this->table)->where_in('username', $username)->limit(0,1)->get();
With success thanks, don't know why i was doing the get in the next line... maybe it was the select('*') that was messing it up.




Theme © iAndrew 2016 - Forum software by © MyBB