Welcome Guest, Not a member yet? Register   Sign In
Deleting selected records
#1

(This post was last modified: 11-01-2016, 10:23 AM by codeguy. Edit Reason: Format )

I've decided to convert an app that I coded procedurally to CI. I'm learning a lot but still have many gaps in my knowledge of CI (and php for that matter). In this case I'd like to delete all records from table 'mz' where the first char of the 'title' field is lower case alpha. This is a test copy of the database that I've messed up while 'learning'. My proposed function:

<MyCode>
public function cleanLibrary () {
        $titleList=$this->db->get('mz');
        foreach ($titleList as $title) {
            if ( ctype_lower($title['title'][0]) && ctype_alpha($title['title'][0]) ) {
                $this->db->delete($title);
            }
        }
}
</MyCode>

It wouldn't be so bad to have to switch to a saved copy of my test database if I screwed up this function - but I'd really like to know if it's as simple as this or if I'm missing something important. Like, will this even work or does it do something I did not intent.
Reply


Messages In This Thread
Deleting selected records - by codeguy - 11-01-2016, 10:18 AM
RE: Deleting selected records - by Wouter60 - 11-01-2016, 12:02 PM
RE: Deleting selected records - by codeguy - 11-01-2016, 03:59 PM
RE: Deleting selected records - by codeguy - 11-01-2016, 04:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB