|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Is there a way to include PHP3-functions or -procedures in a MYSQL-UPDATE-statement?
|
|
#2
|
|||
|
|||
|
Yes, sort of. How depends on what you are trying to do. (hint, hint) URL
|
|
#3
|
|||
|
|||
|
It is fine if you wanted to do something like this:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> <? mysql_query("SELECT * FROM tableName WHERE id='".customPhpFunction($var)."'"); ?> [/quote] What exactly where you trying to do? |
|
#4
|
|||
|
|||
|
Thank you for your quick reply. Ok, here are some more details: I want to update all records in a table at the same time with an update-statement, which should look like this:
------------ UPDATE tableName SET field_1=myPHPfunction('$field_1')"; ====== MyLib.php3: function myPHPfunction($field_1) { $field_1 = [... for example: several different commands to convert special characters ...] return $field_1; } ------------ Although the PHP3 manual states that UDFs must be written in C or C++ and the opereating system must support dynamic loading (under point 14.1) I hope there is a way to realize a.m. example. I know from other programming languages as FoxPro for Windows that you can include „foreign“ functions into an SQL-statement. I tried above UPDATE statement in several different ways but it didn’t work. |
|
#5
|
|||
|
|||
|
UDF's need to be in C, but you can include functions written in php in your script directly or by including or requiring an external file. UDF's become a part of the language itself.
I just reread your post. Are you trying to have a query read the field and modify it based on that read? That can't be done with one query. That's a limitation of MySQL, not PHP. Sorry. Just a note: The latest versions of MySQL DO allow INSERT ... SELECT statements. Unfortunatly, the table(s) referenced in the INSERT cannot appear in the SELECT. I don't believe any SQL engine allows what you are trying to do. Why not just use two queries? Select, modify, update. Rod |
|
#6
|
|||
|
|||
|
Select, modify, update – that’s what I did now. Nevertheless, thanks for your help.
|
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > PHP3-functions in MYSQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|