Welcome Guest, Not a member yet? Register   Sign In
Function :
#1

[eluser]Shaileen[/eluser]
I need the CI code for the following :
$SQL_get_tt_exist = "SELECT count(*) from dsl_tt WHERE order_id = '$quote_id' AND resolved = 0";

$sth2 = $dbh->prepare($SQL_get_tt_exist) or die $dbh->errstr;
$sth2->execute;

$tt_exist = $sth2->fetchrow;
$sth2->finish;

if ($tt_exist) {
$tt_link = "<a href='dsl_tt_list.cgi?searchText=$refid'><img src='$c{url}{public_images}/tt_open.gif' border='0'></a>";
}
else {
$tt_link = "<a href='dsl_tt_list.cgi?searchText=$refid'><img src='$c{url}{public_images}/tt_none.gif' border='0'></a>";
}

if ($quote_id ne 'q10000') {
$quote_link = "<A class='dark' HREF='./t1_quote_view.cgi?index=$quote_id'>Q</A>";
}
else {
$quote_link = "-";
}


I have written the following funtion that can be used :

function get_tt_exist($order_id)
{

$this->db->where('order_id ', $order_id);
$this->db->where('resolved', 0);
$data = $this->db->count_all('dsl_tt');
return $data;


}

How can I use this in my view ?
#2

[eluser]Christopher Blankenship[/eluser]
I am trying to help you, as with your other posts that I have answered.

You really should read and understand exactly what the principles of MVC are in order to fully take advantage of Codeigniter. The question how can I use this in my view? please see the following for more information MVC Information

Simplified of course.
controller(calls model)->model(which is where this information would go)
model(returns information)->controller(collects the information)
controller(passes the data)->view(renders the output)
#3

[eluser]Shaileen[/eluser]
Dude,

I really appreciate your response and am very thankful that you are helping me.

I am very much familier with the MVC framework.
When I meant hwo can i use this in my view, it means that I need the function that is written in perl to be converted to PHP..
#4

[eluser]Christopher Blankenship[/eluser]
Alright that established. I suppose the part that is confusing you is as follows if not let me know otherwise:
Code:
if ($tt_exist) { // test if something returned
$tt_link = “$c{url}{public_images}/tt_open.gif”; // set link using perl hash
}
else {
$tt_link = “$c{url}{public_images}/tt_none.gif”; // nothing returned set link using perl hash
}

In PERL you can utilize arrays and hashes. In this particular instance it is not an array but a hash where $c{url}{public_images}. I added some notes to the above code.

For information on hashes see Perl Hashes Look toward the bottom of the page. This might help you with your conversion. Like I said if that isn't whats hanging you up let me know I would rather help than to do, no one learns that way.




Theme © iAndrew 2016 - Forum software by © MyBB