Skip to content

Instantly share code, notes, and snippets.

@zerowebcorp
Last active August 29, 2015 14:12
Show Gist options
  • Save zerowebcorp/d2627ca157fc5d4fc736 to your computer and use it in GitHub Desktop.
Save zerowebcorp/d2627ca157fc5d4fc736 to your computer and use it in GitHub Desktop.
Find In Set
<?php
$db->find_in_set('503', 'orders')->from('tblinvoices')->fetch();
// Produces: SELECT * FROM tblinvoices WHERE FIND_IN_SET ('305', orders)
$db->where('id', 5)->find_in_set('503', 'orders')->from('tblinvoices')->fetch();
// Produces: SELECT * FROM tblinvoices WHERE id='5' AND FIND_IN_SET ('305', orders)
$db->where('id', 5)->find_in_set('503', 'orders', 'OR')->from('tblinvoices')->fetch();
// Produces: SELECT * FROM tblinvoices WHERE id='5' OR FIND_IN_SET ('305', orders)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment