Welcome Guest, Not a member yet? Register   Sign In
Server closes connection when running sql
#5

[eluser]Kyle123[/eluser]
Yes to both I'm afraid, it's odd. I've tracked it down to a single field in the query. Having replaced the sproc with SQL, executing the following works:
Code:
public function get_newest() {
  $sql = "select top 20
    (rtrim(sender.actfirstname)+' '+rtrim(sender.actsurname)) as [from],
    (rtrim(tot.actfirstname)+' '+rtrim(tot.actsurname)) as [sent],
    convert(text,rntNote) as [note]
     from tb_rntRepnote
     inner join tb_actActor Sender
      on sender.ActKeyactor = RntSendTo
     inner join tb_actActor tot
      on tot.actkeyactor = rntsentby
    where rntCreatedwhen > '2013-01-02 18:55:00'
    and rntclassification = 13
    Order by rntCreatedWhen Desc";
  $query = $this->db->query($sql);
  return $query->result();
But this doesn't:
Code:
public function get_newest() {
  $sql = "select top 20
    (rtrim(sender.actfirstname)+' '+rtrim(sender.actsurname)) as [from],
    (rtrim(tot.actfirstname)+' '+rtrim(tot.actsurname)) as [sent],
    convert(text,rntNote) as [note],
    rntCreatedwhen as createdWhen
     from tb_rntRepnote
     inner join tb_actActor Sender
      on sender.ActKeyactor = RntSendTo
     inner join tb_actActor tot
      on tot.actkeyactor = rntsentby
    where rntCreatedwhen > '2013-01-02 18:55:00'
    and rntclassification = 13
    Order by rntCreatedWhen Desc";
  $query = $this->db->query($sql);
  return $query->result();

rntCreatedwhen is a smalldatetime field.

substituting with the following works:
Code:
convert(datetime,rntCreatedwhen) as createdWhen

Which is fine now I understand it, but it still seems like odd behaviour to me - but having Googled smalldatetime and PHP - there are loads of hits and it appears to be quite a common issue.


Messages In This Thread
Server closes connection when running sql - by El Forum - 01-03-2013, 07:56 AM
Server closes connection when running sql - by El Forum - 01-03-2013, 08:16 AM
Server closes connection when running sql - by El Forum - 01-03-2013, 08:34 AM
Server closes connection when running sql - by El Forum - 01-03-2013, 02:21 PM
Server closes connection when running sql - by El Forum - 01-04-2013, 04:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB