Ben bir kod ateşleyici çaylak duyuyorum. Ben aşağıdaki gibi bir denetleyici var:
<?php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
$this->load->model('usermodel');
}
function index()
{
$res = $this->db->get('users');
die( print_r($res) );
}
}
Benim veritabanında bir tablo 'kullanıcıların' var ve ben üçlü benim veritabanı kimlik bilgilerini kontrol ettirin. Ancak, yazdırma yöntemi sadece "1" baskı tutar. Bu basit sorgu işe neden herkes biliyor musun?
Ayrıca değer bir nesne olduğunu print_r baskılar belirterek ve benim database.php dosyasında true = active_record set vermedi. Bu yardımcı bir durumda, bu çıkış dan
print_r($this->db);
baskılar
CI_DB_mysql_driver Object ( [dbdriver] => mysql [_escape_char] => ` [delete_hack] => 1 [_count_string] => SELECT COUNT(*) AS [_random_keyword] => RAND() [ar_select] => Array ( ) [ar_distinct] => [ar_from] => Array ( ) [ar_join] => Array ( ) [ar_where] => Array ( ) [ar_like] => Array ( ) [ar_groupby] => Array ( ) [ar_having] => Array ( ) [ar_limit] => [ar_offset] => [ar_order] => [ar_orderby] => Array ( ) [ar_set] => Array ( ) [ar_wherein] => Array ( ) [ar_aliased_tables] => Array ( ) [ar_store_array] => Array ( ) [ar_caching] => [ar_cache_exists] => Array ( ) [ar_cache_select] => Array ( ) [ar_cache_from] => Array ( ) [ar_cache_join] => Array ( ) [ar_cache_where] => Array ( ) [ar_cache_like] => Array ( ) [ar_cache_groupby] => Array ( ) [ar_cache_having] => Array ( ) [ar_cache_orderby] => Array ( ) [ar_cache_set] => Array ( ) [username] => root [password] => my_password [hostname] => localhost [database] => bhr_development [dbprefix] => [char_set] => utf8 [dbcollat] => utf8_general_ci [autoinit] => 1 [swap_pre] => [port] => [pconnect] => 1 [conn_id] => [result_id] => [db_debug] => [benchmark] => 0 [query_count] => 0 [bind_marker] => ? [save_queries] => 1 [queries] => Array ( [0] => SELECT * FROM (`users`) ) [query_times] => Array ( [0] => 0 ) [data_cache] => Array ( ) [trans_enabled] => 1 [trans_strict] => 1 [_trans_depth] => 0 [_trans_status] => [cache_on] => [cachedir] => [cache_autodel] => [CACHE] => [_protect_identifiers] => 1 [_reserved_identifiers] => Array ( [0] => * ) [stmt_id] => [curs_id] => [limit_used] => ) 1
UPDATE I tried something like:
$query = $this->db->get("users");
foreach($query->result() as $row){
echo "hello";
}
die();
hiç şans ile. Hala olsun:
Fatal error: Call to a member function result() on a non-object in ...welcome.php...