Welcome Guest, Not a member yet? Register   Sign In
Rewriting query in query builder
#4

This might be what you're looking for. Obviously, I cannot test it so there might be small syntax errors. But this should be pretty close.

I'm not confident that the UNIX_TIMESTAMP part of the select statement will work as desired. That might be part of why "...it just never works," Please tell us what, if any, error messages the code produces.

PHP Code:
$this->db
       
->select("SELECT p_pedestal.*, dev.dev_name AS device, p_port.title AS port, 
                 UNIX_TIMESTAMP(p_pedestal.created) AS created_t, UNIX_TIMESTAMP(p_pedestal.updated) AS updated_t"
)
 
      ->join("p_port""p_pedestal.port_id = p_port.id"'LEFT');

if(
$this->system->isOwner())
{
   $user strtolower($_SESSION['user']['username']) ;
   //Note use of double quotes on second argument, Need them so $user will evaluate.
   $this->db->join('p_port_user_rel'"p_port_user_rel.username = $user AND p_port_user_rel.port_id = p_pedestal.port_id");
}

$query $this->db
   
->join('dev''p_pedestal.dev_id = dev.dev_id''INNER')
   ->order_by('p_pedestal.formatted_address''ASC')
   ->get('p_pedestal') ; 
Reply


Messages In This Thread
Rewriting query in query builder - by roland - 02-08-2019, 05:47 AM
RE: Rewriting query in query builder - by roland - 02-28-2019, 05:47 AM
RE: Rewriting query in query builder - by dave friend - 02-28-2019, 01:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB