Welcome Guest, Not a member yet? Register   Sign In
possible to dynamically place field names and values to each field in insert sql
#1

[eluser]Brad K Morse[/eluser]
I am storing about 25+ values into a oracle database table

Code:
<?php
$student['id'] = "10402";
$student['hnumber'] = "H030502";
$student['name'] = "Larry Wayne";

print_r($student);
?>

It prints out:

Code:
Array ( [id] => 10402 [hnumber] => H030502 [name] => Larry Wayne )

What I want to accomplish is storing values into an array, that will then be inserted into a database table.

So the insert statement would be:

Code:
$q = "insert into table (id, hnumber, name) VALUES ('10401', 'H030502', 'Larry Wayne')";

I want to use an array to store all the values into it, labeling each value by their table field name, because it will be about 25 fields I will be inserting data into.

There has to be a way to accomplish this within codeigniter, even if its not through the use of arrays - I'm all ears.

Thanks in advance.
#2

[eluser]Akinzekeel[/eluser]
Did you try Active Record (the set function in particular)?
#3

[eluser]Brad K Morse[/eluser]
perfect!

thanks.




Theme © iAndrew 2016 - Forum software by © MyBB