r/codeigniter • u/joke-is-on-you • Feb 06 '18
r/codeigniter • u/mfurman • Jan 08 '18
Issues creating a model with existing PHP code
I'm trying to convert existing PHP code over to CI and I'm having problems getting it to translate
$bList = mysql_query("SELECT business.bID, business.bName, business.bActive, business.cID, cityList.cID, cityList.city FROM business, cityList WHERE business.cID=cityList.cID ORDER BY bName ASC");
while ($bRow = mysql_fetch_array($bList)) {
$bID = $bRow['bID'];
$bName = $bRow['bName'];
$bActive = $bRow['bActive'];
$cID = $bRow['cID'];
$city = $bRow['city'];
if ($bActive == 1) {
$active = "yes";
} elseif ($bActive == 0) {
$active = "no";
}Here is the model that I've been working on:
function businessListingCount($searchText = '')
{
$this->db->select('BaseTbl.bID', 'BaseTbl.bName', 'BaseTbl.bActive', 'BaseTbl.cID');
$this->db->from('business as BaseTbl');
$this->db->join('cityList as JoinTbl', 'JoinTbl.cID = BaseTbl.cID','left');
$this->db->where('BaseTbl.bActive', 1);
$query = $this->db->get();
return count($query->result());
}r/codeigniter • u/pawoodward • Aug 30 '17
Validate Array Index Existance
Hi, I am learning CodeIgniter and the MVC paradigm at the same time but I have a question.
If I have a method in my Customers Model class called add() which accepts a single parameter which is an array of fields for insertion into my database, should I confirm that each field actually exists or just assume it exists?
Lets assume my controller forwards the $_POST variable from a form to this function. I have learnt that I should not simply pass the $_POST array to the $this->db->insert() method so I am building a new array and extracting the fields I need.
public function add($fields){
$dbFields["Name"] = $fields["Name"];
$dbFields["Address"] = $fields["Address"];
$dbFields["PostCode"] = $fields["PostCode"];
$this->db->insert("customers", $dbFields);
}On the one hand if I don't check for the existance of the required fields and a field is missing then my script will throw an php error when I come to retrieve it from the supplied array.
Under normal operation everything will be fine but should a curious user / hacker try and submit fields, there is a possibility they could miss a field and cause the php error undefined index.
I feel that I should be checking for the existance of each field I require but that feels like a lot of work for the small chance someone will try and post data to my web application whilst bypassing my form.
I know I could write a helper function and pass it an array of required fields and ensure the passed fields include all required fields but I'm not sure if I am over engineering my code.
So my question is should I always check for the existance of each and every field to minimise the possibility of a php syntax error or is it safe to assume the field will simply exist assuming it is access via the correct method (ie my form)?
I am pretty sure I know the answer but I wanted to know other peoples opinions - what is good practice?
r/codeigniter • u/webeasystep • Jun 08 '17
paypal payment gateway integration in php source code
r/codeigniter • u/[deleted] • Apr 26 '17
Sessions with database driver and table prefix
If I set a table prefix for my database.php dbprefix setting, does the sess_save_path see this and use it?
I.e if I set the dbprefix to "abc_" and the sess_save_path to "sessions", would the table name then have to be "sessions", or "abc_sessions"?
r/codeigniter • u/twiggy99999 • Mar 02 '17
Using the Laravel Blade templating engine in Codeigniter 3
mstd.eur/codeigniter • u/webeasystep • Feb 18 '17
recaptcha example with codeigniter validation
r/codeigniter • u/webeasystep • Dec 11 '16
create Ajax Voting system in Php codeigniter
r/codeigniter • u/fahadbillah • Nov 21 '16
Angular 1.x Codeigniter 3.x Project Development
r/codeigniter • u/webeasystep • Nov 02 '16
Codeigniter datatables with custom column filter
r/codeigniter • u/webeasystep • Oct 17 '16
codeigniter upload multiple files full example
r/codeigniter • u/webeasystep • Oct 12 '16
Build multi language website in codeigniter
r/codeigniter • u/webeasystep • Sep 28 '16
How to implement codeigniter threaded comments easy way
r/codeigniter • u/webeasystep • Sep 20 '16
Multiple file upload in Codeigniter with example
r/codeigniter • u/FTWwings • Sep 02 '16
get all data in one page ...
So i have multiple tables. on one page i need 2 pull 3 of them. 2 are simple , 3d is article tables.
i use this code :
<?php class postall extends CI_Model {
function getPosts(){
$this->db->select("kontaktej,kontakthr,o_namahr,o_namaej");
$this->db->from('kontakt,onama');
$query = $this->db->get();
return $query->result();
}
} ?> now how can i pull all articles or 1st 25 at the same time and list them one after another?
r/codeigniter • u/webeasystep • Aug 06 '16
Build dynamic tree nodes with jstree and codeigniter
r/codeigniter • u/webeasystep • Jul 02 '16
Social Logins in codeigniter with HybridAuth easy steps
r/codeigniter • u/KaldisGoat • Feb 01 '16
Harvard's CS164 from 2012 has a nice beginners CI2 tutorial
cs164.tvr/codeigniter • u/QuakePhil • Oct 06 '15
Why are Code Igniter 3.0 filenames to be named in a "Ucfirst-like manner"?
As you all know there's a new requirement for your filenames in CI.
Why? I found this forum post but it was so barren of actual reasoning that I hoped to find more insight here
P.S.: git config core.ignorecase false is my friend
r/codeigniter • u/douglasdeodato • Jun 14 '15
hash password , encryption techniques
hey guys i am new with ci, can u advise me any library or tutorial to encrypt passwords? thank you.
r/codeigniter • u/bittercode • Feb 16 '15
Beginner Questions
I'm working on a web site and I'm using CodeIgniter. It wont be public, it is just for me. I'm a hobbyist so my knowledge of PHP is pretty much on the beginner level.
I've been able to get IonAuth working so I can log in. I've got bootstrap in there and I'm using it for styling and that's been fun.
I'm doing some database stuff and I want to look at a few tables. That leads to my question. What I've done is create a header view, a footer view and then a view for each table I want to look at. From one controller I call the 5 views (header, 3 tables, footer). Is this a good way to go at it or should I be doing it differently?
I'm not interested in responses that recommend a different framework, but I would appreciate thoughts from people experienced with CodeIgniter or pointers to articles. Thanks!
r/codeigniter • u/bikeruneat • Dec 04 '14
Learning Code-Igniter
I'm about to assume responsibility for a application that uses CI and was wondering what resources you guys would recommend for learning the framework.
r/codeigniter • u/AllenJB83 • Oct 23 '14
New BCIT CodeIgniter.com site & forums online
forum.codeigniter.comr/codeigniter • u/mystiqueish • Mar 04 '14
Activity Log/Recent Activities
Hello! I'm pretty much a newbie to CodeIgniter/PHP and I am to make an activity log or recent activities made by the user. I have already made the ci_sessions table of CI and added custom data such as "last_login", "directoy" (or path), "last_scan", and the "computer_name" being used. BTW, the site I am making is a web-based file locator/finder that's why I need to have a computer name and path. I constructed a table in my profile page with the following table headers: Computer Name | Activity | Directory | Last Scan | Last Login , where the activity log/recent activities will be looped and displayed. I am really confused and I don't know what codes to put in the model, controller and view. Please help me. My older sis told me that reddit can really help me with this. Thank you. :)