模型函数返回空一列

时间:2017-03-13 15:54:48

标签: php sql codeigniter

主要照片

我创建了发送到控制器ID的更新表单,一切正常。但是,我检查的主要照片会返回首先添加的数据。例如,event_id = 2没有主图片,event_id = 4有main_photo(例如:test)但它得到event_id = 2空值。我花了很多时间却无法找到解决方案。

潜行

public function get_list_for_edit($event_id){
    return
    $this->db->select('*')
              ->select('pn.title as push_title, e.title as event_title', false) 
              ->from('events e')
              ->join('events_locations el','el.event_id =' . $event_id,'left')
              ->join('push_notifications pn',
                      'pn.type_id ='. $event_id,'left')

              ->get('events')
              ->row_object();
}

数组1 event_id = 2

  stdClass Object
   (
[event_id] => 2
[title] => test1 -pushnotificationtitle
[description] => <p>Test1 -description</p>
[main_photo] => 
[start] => 2017-03-12 08:00:00
[end] => 2017-03-15 06:00:00
[phone] => 946871783
[email] => abdurasulov.ravshan@gmail.com
[keywords] => test1 -keywords
[created_at] => 2017-03-12 20:29:09
[status] => active
[deleted] => 0
[event_location_id] => 2
[country_id] => 1
[city_id] => 1
[area_id] => 1
[street] => Tinchlik street
[building_no] => Tinchlik street
[latitude] => 25.218670435768225
[longitude] => 55.29264020500705
[push_notificaion_id] => 2
[type] => event
[type_id] => 2
[datetime] => 2017-03-12 20:29:09
[message] => test1 -pushnotificationmessage
[push_title] => test1 -pushnotificationtitle
[event_title] => Test1
 )

数组2 event_id = 5

stdClass Object
 (
[event_id] => 5
[title] => test4 - notificationtitle
[description] => <p>Test1 -description</p>
[main_photo] => 
[start] => 2017-03-12 08:00:00
[end] => 2017-03-15 06:00:00
[phone] => 946871783
[email] => abdurasulov.ravshan@gmail.com
[keywords] => test1 -keywords
[created_at] => 2017-03-12 20:45:47
[status] => active
[deleted] => 0
[event_location_id] => 5
[country_id] => 1
[city_id] => 1
[area_id] => 1
[street] => Tinchlik street
[building_no] => Tinchlik street
[latitude] => 25.197858466144194
[longitude] => 55.244231696706265
[push_notificaion_id] => 5
[type] => 
[type_id] => 5
[datetime] => 2017-03-17 08:00:00
[message] => test4 - notificationtitle
[push_title] => test4 - notificationtitle
[event_title] => Test1
  )

1 个答案:

答案 0 :(得分:0)

如果我理解正确并且您需要获得一张图片但主图像可能可用或不可用,我就是这样做的:

控制器:

let someImageView: UIImageView = {
   let theImageView = UIImageView()
   theImageView.image = UIImage(named: "yourImage.png")
   theImageView.translatesAutoresizingMaskIntoConstraints = false //You need to call this property so the image is added to your view
   return theImageView
}()

型号:

    static void Main(string[] args)
    {
        String returnedValue = Method1();
    }

    public static string Method1()
    {

        Console.Write("Vorname: ");
        string vorname = Convert.ToString(Console.ReadLine());
        Console.Write("Nachname: ");
        string nachname = Convert.ToString(Console.ReadLine());
        Console.Write("Adresse: ");
        string adresse = Convert.ToString(Console.ReadLine());

        string info = vorname + nachname + adresse;
        return (info);

    }