EllisLab text mark
Advanced Search
     
[HELP] array codeigniter
Posted: 28 October 2012 11:51 PM   [ Ignore ]
Joined: 2012-10-28
1 posts

i have tried to make sql code in CI, the problem is the ID_LABEL at t_publisher is filled with 0 where it should filled with number that taken from t_label..

$sql[‘query1’] = “INSERT into t_user (USER_NAME, USER_PASS, USER_STATUS, USER_TYPE) values (’$user’, ‘$pass’,‘1’,‘publisher’)”;
$sql[‘query2’] = “INSERT INTO t_label (LABEL) values(’$user’)”;
$id_label = “select id_label from t_label where label =’”.$user.”’”;
$id = $this->db->query($id_label)->result();
$sql[‘query3’] = “INSERT INTO t_publisher (PUBLISHER, ARTIS, ID_LABEL) values(’$user’, ‘Various Artist’, ‘$id’)”;
$result = array();
foreach($sql as $key => $value){

$result[$key] = $this->db->query($value);
}

please help smile

 
Posted: 29 October 2012 06:32 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2009-04-30
76 posts
$sql[‘query3’] “INSERT INTO t_publisher (PUBLISHERARTISID_LABELvalues(’$user’‘Various Artist’‘$id->id_label’)

Generating query results: http://ellislab.com/codeigniter/user-guide/database/results.html

And escape your queries. Please read last two sections from user guide: http://ellislab.com/codeigniter/user-guide/database/queries.html