i need autocomplete in netbeans with codeigniter database mysql objects.
I have enabled autocomplete for standard classes, but if i get mysql results there is nothing (because of dynamically created objects via http://php.net/manual/en/function.mysql-fetch-object.php
My workaround is to declare a model_raw class that just contains the fields.
/**
*
* @param int $id
* @return Account_model_raw
*/
public function get_Account($id) {
if (is_int($id) === FALSE)
return null;
$query = $this->db->get_where($this->table, array('id' => $id), 1);
if ($query->num_rows() <= 0)
return null;
$ret = $query->row();
return $ret;
}
class Account_model_raw{
var $id;
var $login;
var $password;
var $lastlogin;
}
And now i can get the autocomplete in netbeans if i use a the get_Account Method.
MY QUESTION is if there is a nicer way AND to keep the class synchronized with the mysql. what if a table changes? i dont want to manually edit the database and the raw class files.
Maybe those raw files can be created automatically with a script?
You could use MY_Model or an ORM Library.
https://github.com/jamierumbelow/codeigniter-base-model
http://redbeanphp.com/
So you dont need to declare explicitly in your model if you are using X and Y object, you use these library in a way you declare your Model using X table and then you can call unto the function the ORM provides to access the field values in your Database.
PS : Dont rely on Autocomplete for these types of functionality, though you will not see what is in your DB from your NetBeans you can atleast rely on the library to know where to place x,y object you provide for it.