English 中文(简体)
我的《公认简明的财富法》有什么错误?
原标题:What s wrong with my CodeIgniter SQL simple Query?

I just have a little question about a query making me crazy. I m working with CI, and tis is the first time i m using this great framework

1— Okay so I have an insert query working rather well :

$data = array(

  nom  => $nom,
  prenom  => $prenom,
  login  => $prenom.   .$nom,
  password  =>  facebook ,
  email  => $fb_data[ me ][ email ],
  mobile  => "00",
  etat  => "1",
  role  => "1",
  ville  =>  ville actuelle ,
  facebook_id  => $fb_data[ uid ],     
);

$this->db->insert( membre , $data);  

我不理解,为什么它总是两次插入数据......!

2— Then I got a second question : I just wanna found a user with the related facebook_id so i try that :

$this->db->select( nom );
$this->db->from( membre );
$this->db->where( facebook_id ,$fb_data[ uid ]);
$resultat=$this->db->get();

echo  <pre> ;
print_r($resultat);
echo  </pre> ;  

我也试图:

$resultat2 = $this->db->get_where( membre ,array( facebook_id  => $fb_data[ uid ]));
echo  <pre> ;
print_r($resultat2);
echo  </pre> ;  

但在这两种情况下,唯一的一阵是:

CI_DB_mysql_result Object
(
  [conn_id] => Resource id #36
  [result_id] => Resource id #61
  [result_array] => Array
      (
      )

  [result_object] => Array
      (
      )

  [custom_result_object] => Array
      (
      )

  [current_row] => 0
  [num_rows] => 1
  [row_data] =>
)

因此,[结果_id]是oka,但是没有数据(只要应该用[数据]印刷?) 当我简单地尝试我方言时,右派成员就会取得正确结果。 但是,与 CI一样,它似乎没有工作。

3— Furthermore, when i Try something like that :

echo $resultat[ nom ];  

它没有被视为一个阵列。

因此,我根本不理解。 如果有人能向我强调的话?

最佳回答

不要忘记最终使用结果方法,否则你只能获得资源。 与此类似:

$resultat2 = $this->db->get_where( membre ,array( facebook_id  => $fb_data[ uid ]))->result();

这回答了第二个和第三个问题,就第一个问题而言,我需要看一下你如何称呼这个问题,而《守则》看上去是oka的,我的话或许是说两点。

问题回答

1 - 你们是否相信你不会两次打上<条码>(......)? 或许可以使用<代码>$this->db->last_query()查看结果查询。

页: 1

将与你合作

$this->db->select( nom );
$this->db->from( membre );
$query = $this->db->get_where( facebook_id ,$fb_data[ uid ]);
$row= $result->row();

echo  <pre> ;
echo $row->uid ; // that will prent user id , you can change to what ever you want ex.  i want tp prent username it will be like this $row->username it should be same as database column 
echo  </pre> ;  




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签