I'm making a school project on which I have to create a web app based on a Oracle database, and after testing some php frameworks I'm currently using CodeIgniter. I'm pretty new to the MVC and php, so excuse me if I make any mistake..
I understand that (beeing a MVC framework), on my Model, it's possible to run queries like
$query = $this->db->query("SELECT * FROM tablename");
But on my studies I read that it's good practice to, everytime we want to run a query/insert/etc, we should open a connection and end it after making the operation. I believe that's supposed to prevent 'inconsistencies'..Something like
<?php
$conn = oci_connect('user', 'pass', 'dbname');
$query = 'select * from tablename';
$stid = oci_parse($conn, $query);
oci_execute($stid, OCI_DEFAULT);
while ($row = oci_fetch_array($stid, OCI_ASSOC)) {
foreach ($row as $item) {
echo $item." | ";
}
echo "
\n";
}
oci_free_statement($stid);
oci_close($conn);
?>
Is that so? If it is, then the that command I'm making on my Model is correct or not? I can only think of running this php script on a view.php file but by doing so I guess I'm not implementing the MVC 'concept', just calling this kind of php script...right? I'm getting the results with the two method, but im not sure which's the best way to do it..
Thanks in advance!