رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
مشکل در نمایش اطلاعات جدول بانک
#1
این فایل های BlogModal هست :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
 
class BlogModal extends CI_Model {
 
   public function __construct() {
       parent::__construct();
       // Your own constructor code
   }
 
   //$this->load->database();
   function getAllPost() {
       $this->db->get('user');
   }
 
}
 
?>


و این هم کدهای فایل Blog.php که Controller هست :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
 
defined('BASEPATH') OR exit('No direct script access allowed');
 
class Blog extends CI_Controller {
 
   function index() {
       //$this->load->view('BlogView');
       $this->load->model('BlogModal');
       $posts = $this->BlogModal->getAllPost();
       print_r($posts);
   }
 
}
در خروجی چیزی نمایش داده نمی شود.
تشکر
پاسخ
تشکر شده توسط:
#2
الآن یک return قبل از دستور :
1
$this->db->get('user');
قرار دادم . اطلاعات نمایش داده شد اما طالاعات جدول بانک نیست!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
CI_DB_mysqli_result Object
(
   [conn_id] => mysqli Object
       (
           [affected_rows] => 2
           [client_info] => mysqlnd 5.0.11-dev - 20120503 - $Id: 15d5c781cfcad91193dceae1d2cdd127674ddb3e $
           [client_version] => 50011
           [connect_errno] => 0
           [connect_error] =>
           [errno] => 0
           [error] =>
           [error_list] => Array
               (
               )
 
           [field_count] => 7
           [host_info] => localhost via TCP/IP
           [info] =>
           [insert_id] => 0
           [server_info] => 5.5.5-10.1.13-MariaDB
           [server_version] => 50505
           [stat] => Uptime: 8967  Threads: 1  Questions: 1618  Slow queries: 0  Opens: 30  Flush tables: 1  Open tables: 41  Queries per second avg: 0.180
           [sqlstate] => 00000
           [protocol_version] => 10
           [thread_id] => 188
           [warning_count] => 0
       )
 
   [result_id] => mysqli_result Object
       (
           [current_field] => 0
           [field_count] => 7
           [lengths] =>
           [num_rows] => 2
           [type] => 0
       )
 
   [result_array] => Array
       (
       )
 
   [result_object] => Array
       (
       )
 
   [custom_result_object] => Array
       (
       )
 
   [current_row] => 0
   [num_rows] =>
   [row_data] =>
)
پاسخ
تشکر شده توسط:
#3
شما خود کوئری رو داری بر میگردونی در حالی که باید نتیجه کوئری رو برگردونی

1
2
3
function getAllPost() {
       $query = $this->db->get('user');
       return $query->result();
پاسخ
تشکر شده توسط:




کاربران در حال بازدید این موضوع: