Get the week number from a datetime
@param $field A datetime expression
@param $which_connection see method close()
@return The SQL expression
188848
public function week($field,$which_connection='')
    {
        if ($which_connection == '') {
            $which_connection = $this->default_db;
        }
        $conn = $this->connections[$which_connection];

        return $conn->SQLDate("W",$field);
    }
184212
public function value($field, $default = null)
    {
        $this->parseOptions();

        return $this->connection->value($this, $field, $default);
    }
916123
function getWeekNumber(date) {
  date = this.toDate(date);
  var week = this._startWeek;
  return date ? getWeekNumberFn(date, week, this.startMonth): null;
}
1343052
public function error($which_connection='')
    {
        $con = $this->getNamedConnection($which_connection);

        if (!is_object($con)) {
            if ($this->last_connect_error) {
                return $this->last_connect_error;
            }

            return 'No database connection';
        }

        return $con->ErrorMsg();
    }
782677
public function where_lt($field = '', $x)
	{
		$this->_where_init($field);
		$this->wheres[$field]['$lt'] = $x;
		return($this);
	}
512444
public function fetchColumn($table, $field, $where = null, $options = null)
    {
        return $this->column($table, $field, $where, $options);
    }
148532
public function currency($which_connection='')
    {
        $which_connection = $which_connection === '' ? $this->default_db : $which_connection;
        $adapter = $this->getAdapter($this->connectionType($which_connection));
        return $adapter->currency();
    }
922086
public function field($field) {
        $field = is_array($field) ? $field : explode(',', $field);
        foreach ((array) $field as $k => $v) {
            $this->build()->bindExpression('field', $v);
        }

        return $this->connection;
    }
776155
public function now($which_connection='')
    {
        if ($which_connection == '') {
            $which_connection = $this->default_db;
        }

        return $this->connections[$which_connection]->sysTimeStamp;
    }
1284054
public function orWhereRaw($field, $operator = null, $value = null)
    {
        return $this->where($field, $operator, $value, 'or', true);
    }
1150442
protected function getAddressFieldValue($field)
    {
        if ($field instanceof \Closure) {
            return call_user_func($field, $this);
        }

        if (is_array($field)) {
            return $this->getRelationalField($field);
        }

        return $this->{$field};
    }
640110
public function next($entity, $field = 'datepublish', $where = [])
    {
        if ($field[0] === '-') {
            $operator = '<';
            $field = substr($field, 1);
            $order = '-' . $field;
        } elseif ($field[0] === '+') {
            $operator = '>';
            $field = substr($field, 1);
            $order = $field;
        } else {
            $operator = '>';
            $order = $field;
        }
        $params = [
            $field         => $operator . $entity->get($field),
            'limit'        => 1,
            'order'        => $order,
            'returnsingle' => true,
        ];
        $params = array_merge($params, $where);

        return $this->query->getContent((string) $entity->getContenttype(), $params);
    }
469916
public static function dateTimeSql2PHP($sqlField,&$hasTime=false)
	{
		// 3  2016-01-31 00:00:00 -> 01/01/2016 00:00:00
		// mysql always returns the date/datetime/timestmamp in ansi format.
		if ($sqlField === "" || $sqlField===null) {
			if (DaoOne::$dateEpoch===null) return null;
			return DateTime::createFromFormat('Y-m-d H:i:s.u',DaoOne::$dateEpoch);
		}
		if (strpos($sqlField, '.')) {
			// with date with time and microseconds
			$hasTime=true;
			return DateTime::createFromFormat('Y-m-d H:i:s.u', $sqlField);
		} else {
			if (strpos($sqlField, ':')) {
				// date with time
				$hasTime=true;
				return DateTime::createFromFormat('Y-m-d H:i:s', $sqlField);
			} else {
				// only date
				$hasTime=false;
				return DateTime::createFromFormat('Y-m-d', $sqlField);
			}
		}
	}
122676
public static function sqlDate($date, $field_name = 'date')
    {
        if (preg_match('/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/', $date, $matches)) {
            if (checkdate($matches[2], $matches[3], $matches[1])) {
                return $date;
            }
        }
        throw new IncorrectParametersException([ $field_name]);
    }
1038820
public static function of(int $dayOfWeek) : DayOfWeek
    {
        Field\DayOfWeek::check($dayOfWeek);

        return DayOfWeek::get($dayOfWeek);
    }
920836
public function getTotalData($field = null, $idValue = null)
	{
	    $select = $this->tableGateway->getSql()->select();
	    
	    if (!empty($field) && !empty($idValue))
	    {
	    	$select->where(array($field => (int) $idValue));
	    }
	    
	    $resultSet = $this->tableGateway->selectWith($select);

	    return $resultSet->count();
	}
1229439
public function checkExistsWithMultipleWhere($whereValue = '', $whereField = 'id', $select = '*')
    {
        if (is_array($whereValue) && count($whereValue) > 0) {
            foreach ($whereValue as $key => $value) {
                if (is_array($value['value'])) {
                    $this->db->where($value['field'], $value['value'], self::OPERATOR_IS_IN);
                } else {
                    $this->db->where($value['field'], $value['value'], $value['operator']);
                }
            }
        } else {
            $this->db->where($whereField, $whereValue, self::OPERATOR_EQUAL_TO);
        }
        $this->db->get($this->table, NULL, $select);

        return (int) $this->db->count;
    }