Questions tagged [create-function]
114 questions
0
votes
1 answer
MySQL function declare 2 variables with one select
I'd like to know how I can create a MySQL function that declares 2 variables by using 1 select statement.
Something like this:
CREATE FUNCTION `inHashtagCampaign` (campaignId INT,startDateTime DATETIME,endDateTime DATETIME)
RETURNS TEXT
LANGUAGE…
user936965
0
votes
2 answers
How to fix MySQL CREATE FUNCTION query?
I want to add mysql function:
CREATE FUNCTION `chf_get_translation`(translation_id INT, site_lang INT)
RETURNS text CHARSET utf8
BEGIN
DECLARE translation TEXT;
SELECT title
INTO translation
FROM chf_translations
WHERE key_id =…

Liutas
- 5,547
- 4
- 23
- 22
0
votes
3 answers
what does this preg_replace_callback do in PHP? and how do I stop it leaking memory?
I've got a section of code on a b2evo PHP site that does the following:
$content = preg_replace_callback(
'/[\x80-\xff]/',
create_function( '$j', 'return "".ord($j[0]).";";' ),
$content);
What does this section of code do? My guess…

seanyboy
- 5,623
- 7
- 43
- 56
0
votes
1 answer
MySQL Workbench 6.2 create function
I'm trying to create a function in MySQL workbench, I have this SQL code:
DELIMITER $$
CREATE FUNCTION `regex_replace` (pattern VARCHAR(1000),replacement VARCHAR(1000),original VARCHAR(1000))
RETURNS VARCHAR(1000)
DETERMINISTIC
BEGIN
DECLARE temp…
user936965
0
votes
1 answer
Creating temporal functions with dynamically generated names in jQuery
I have an external javascript file which is loaded dynamically, and it has an oncomplete= variable, which increases its value each time that it is called. For example:
First time: external.js?oncomplete=sayHello1
Second time:…

Andres SK
- 10,779
- 25
- 90
- 152
0
votes
1 answer
preg_replace - replaced content returns at the begining of output
I lost a lot of time because of that issue, and I'm really resigned..
When I using preg_replace with create_function , all results going at the beggining of output, but they should be in the place of founded match, just like:
COMPONENT1 COMPONENT2…

Arek Dudys
- 25
- 4
0
votes
1 answer
How would I make this a UDF
Problem: How to make a UDF from the following working code.
declare @currentweek as date
declare @1stweek as date
declare @2ndweek as date
declare @3rdweek as date
declare @4thweek as date
declare @5thweek as date
set @currentweek=…

Brian
- 31
- 5
0
votes
1 answer
mySQL Create Function
Can anyone help work out why this create function isn't working. I've copied it from a a program teaching me mySQL and I've double checked and it doesn't seem to work.
any help greatly appreciated
Delimiter//
Create Function CAP_FIX(Input…

James Slasor
- 35
- 7
0
votes
1 answer
How to create a function in PostgreSQL?
I`ve got only one database which name is "testDB".
In command line:
1)
psql testDB
2)
create a function as easies as is possible:
CREATE or replace FUNCTION testFun()
RETURNS integer AS $total$
declare
total integer;
BEGIN
SELECT count(*)…

andrew
- 3,083
- 4
- 24
- 29
0
votes
1 answer
Converting Anonymous Function to 5.2 create_function
I'm attempting to convert:
usort($discounts, function ($a, $b) use ($c, $d){
$value1 = $c->do_action($a, $d, $d->value);
$value2 = $c->do_action($b, $d, $d->value);
return $value1 == $value2 ? 0 : ($value1 > $value2 ? 1 : -1);
});
Into…

Chris
- 1,881
- 3
- 20
- 27
0
votes
1 answer
PHP create_function returns false
Situation:
This works:
$functionCode = 'return ($myvar1 == "something") && ($myvar2 != "");';
$newfunc = create_function($functionParamsConcat, $functionCode);
But the problem is that the funcitonCode is dynamic, and the boolean expression inside…

mpinvidio
- 489
- 6
- 17
0
votes
1 answer
What's the syntax to get a create_function function to work as a callback:
I attempted the following code:
$for_callback=create_function('$match','return $GLOBALS[\'replacements\'][$match[1]];');
$result = preg_replace_callback( $regex, '$for_callback', $string);
The variable $GLOBALS['replacements'] is generated…

TecBrat
- 3,643
- 3
- 28
- 45
0
votes
2 answers
PHP create_function with nested arrays
I need to use create_function because the server the application is running on has an outdated version of PHP.
The issue is that the items I pass into usort are arrays and I need to sort by a value within the array:
$sort_dist = create_function(…

Matt
- 5,547
- 23
- 82
- 121
0
votes
5 answers
PHP: How to make variable visible in create_function()?
This code:
$t = 100;
$str = preg_replace_callback("/(Name[A-Z]+[0-9]*)/",
create_function(
'$matches',
'return $matches[1] + $t;'
…

Blueberry Hill
- 119
- 4
- 12
-1
votes
4 answers
create_function in php
Possible Duplicate:
Is there a PHP function to remove any/all key/value pairs that have a certain value from an array?
Remove zero values from a PHP array
I have one array like this.
[notify_emp] => Array
(
[224] => 0
[228] => 0
…

Krunal Shah
- 567
- 1
- 10
- 24