db::where PHP Method

where() static public method

A handler to convert key/value arrays to an where clause
static public where ( array $array, string $method = 'AND' ) : string
$array array keys/values for the where clause
$method string AND or OR
return string The MySQL string for the where clause
    static function where($array, $method = 'AND')
    {
        if (!is_array($array)) {
            return $array;
        }
        $output = array();
        foreach ($array as $field => $value) {
            $output[] = $field . ' = \'' . self::escape($value) . '\'';
            $separator = ' ' . $method . ' ';
        }
        return implode(' ' . $method . ' ', $output);
    }

Usage Example

Example #1
0
 function newPassword($new_pass)
 {
     if (!empty($new_pass)) {
         db::table('admin_users');
         db::where('user_id', ADMIN_USER_ID);
         db::update('user_password', md5($new_pass));
     }
 }
All Usage Examples Of db::where