CodeIgniter Forums
MySQL Text field - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: MySQL Text field (/thread-13195.html)



MySQL Text field - El Forum - 11-14-2008

[eluser]attosolutinos[/eluser]
I am new to this framework and I have relay enjoyed it so far. I have run into t a little snage that I need some help with. I have a table with the text field in it. It is a MySQL table. When I query the data from a query browser I get a value in the field but through the active data result it is blank. Is there something special I should know about using text fields??? Thanks for your help in advance.

brian


MySQL Text field - El Forum - 11-14-2008

[eluser]Unknown[/eluser]
Hello,

Would you have some source to show?


MySQL Text field - El Forum - 11-14-2008

[eluser]attosolutinos[/eluser]
Ok here is the code that I am using. first the create table from mysql:
CREATE TABLE `member` (
`memberid` int(10) unsigned NOT NULL auto_increment,
`farmid` int(10) unsigned NOT NULL,
`prifirstname` varchar(60) NOT NULL,
`prilastname` varchar(60) NOT NULL,
`pristreet1` varchar(60) NOT NULL,
`pristreet2` varchar(60) NOT NULL,
`pricity` varchar(45) NOT NULL,
`pristate` varchar(10) NOT NULL,
`pridayphone` varchar(20) NOT NULL,
`prievephone` varchar(20) NOT NULL,
`priemail` varchar(60) NOT NULL,
`priemail2` varchar(60) NOT NULL,
`parfirstname` varchar(60) NOT NULL,
`parlastname` varchar(60) NOT NULL,
`parstreet1` varchar(60) NOT NULL,
`parstreet2` varchar(60) NOT NULL,
`parcity` varchar(60) NOT NULL,
`parstate` varchar(60) NOT NULL,
`parzip` varchar(10) NOT NULL,
`prizip` varchar(10) NOT NULL,
`pardayphone` varchar(20) NOT NULL,
`parevephone` varchar(20) NOT NULL,
`paremail` varchar(60) NOT NULL,
`pickupid` int(10) unsigned NOT NULL,
`pickupcounty` varchar(45) NOT NULL,
`homedelivery` bit(1) NOT NULL,
`locationhost` bit(1) NOT NULL,
`fielddays` bit(1) NOT NULL,
`willhelp` bit(1) NOT NULL,
`comments` text NOT NULL,
`farmernotes` text NOT NULL,
`referredby` varchar(200) NOT NULL,
`signup` date NOT NULL,
`paymentplan` int(10) unsigned NOT NULL,
`farmernumber` varchar(45) NOT NULL,
PRIMARY KEY (`memberid`),
KEY `farmid` (`farmid`),
KEY `pickupid` (`pickupid`)
) ENGINE=MyISAM AUTO_INCREMENT=3631 DEFAULT CHARSET=latin1 COMMENT='Member table'

Now that you have that here is the query that I use to go and get the record. This function is in a model.
function MemberReview($farmid,$Sort){
$this->db->select("concat(prifirstname, ' ',prilastname) as `Name`,
prizip as `Zip`,pridayphone as `DayPhone`,
prievephone as `EvePhone`,
priemail as `Email`,memberid",FALSE);
if ($Sort == "" || $Sort == "name"){
$this->db->order_by('prilastname');
} elseif ($Sort == "zip"){
$this->db->order_by('prizip');
} else {
$this->db->order_by('priemail');
}
$query = $this->db->get_where("csa.member",array('farmid'=>$farmid),'',False);
return $query;
}
Here is my function from the controller:
function members($Sort=""){
// this will go through and gather all the members and show them
$this->load->model('farmermodel');
//$this->load->library('form');
$this->load->library('table');
$MemberTable = $this->farmermodel->MemberReview($this->session->userdata("farmid"),$Sort);
// wee need to build an array then pass the array to the view
//print_r($MemberTable);

$tabledata=array();
foreach ($MemberTable->result() as $row){
$memberlink = "<a >memberid ."\">" . $row->Name . "</a>";
$emaillink = "<a >Email . "\">" . $row->Email . "</>";
$temp = array("Name"=>$memberlink,
"Zip" =>$row->Zip,
"DPhone"=>$row->DayPhone,
"EPhone"=>$row->EvePhone,
"Email"=>$emaillink);
$tabledata[$row->memberid] = $temp;
}
$data=array('Memebers'=>$tabledata);
$this->load->view('farmer/head.php');
$this->load->view('farmer/topBanner');
$this->load->view('farmer/menu');
$this->load->view('farmer/farmMember',$data);
$this->load->view('farmer/bottomBanner');
$this->load->view('farmer/footer');
}
No in the farmMember view I am accessing the data using the $farmernotes. When I print out the results array that field is empty. Does that help?


MySQL Text field - El Forum - 11-14-2008

[eluser]Murodese[/eluser]
You're not selecting the farmernotes field in your query.


MySQL Text field - El Forum - 11-15-2008

[eluser]attosolutinos[/eluser]
You are correct. That function does not select the field that is because it is the wrong function. Here is the correct function

$this->db->where(array('memberid'=>$id));
$this->db->join("csa.pickuploc","member.pickupid=pickuploc.pickupid");
$query = $this->db->get("csa.member");
return $query;

I have not tried to build my own query and try that yet. But that is my next step. any other suggestions???