Using php string function on update and/or insert
So, for instance, I want to place a month/day in a column but I want the insert or update to strip out any forward-slash character that might be submitted.
How do I get str_replace() to be applied on insert or update to prevent the insertion of a forward-slash.
I am having trouble figuring out to what I should apply function. There's nothing in the form's value field and even if I echo in a variable or something like this:
echo $row_rssubscription_payment_copy['expirationDate'];
I have trouble "seeing" what the syntax should be. My guesses are all wrong.
Will someone please lend a hand.
Thanks very much!
Hi alterity,
if you´d use ADDT´s datepicker, you wouldn´t need to worry about that :-)
honestly, if a column like "expirationDate" is supposed to store the year-month-day value in a mysql compatible format, I can´t think of any reason to not use the datepicker.
However it´s possible to apply stuff like that to a certain transaction value before it´s getting submitted to a table -- here´s a str_replace example which would replace a forward slash (/) with a hyphen:
$tNG->setColumnValue("columnname_here", str_replace('/','-',$tNG->getColumnValue("columnname_here")));
All you´d need to do, is to embed such things in a Custom Trigger and make sure it´s defined as BEFORE trigger.
Cheers,
Günter Schenk
Adobe Community Expert, Dreamweaver
Similar Messages
-
How to use SQL String functions with JPA and SAP NW
Hi Everyone,
I'm recently got the following problem:
I have a Web Service project using JPA. But as i found out SAPs JPA implementation or more precisely openSQL restricts the use of the LOWER() function, which converts a String to lower case.
Now I am looking for some sort of workaround. I want to execute the following JPQL query:
SELECT bp FROM BusinessPartner bp WHERE LOWER(bp.companyName) LIKE LOWER(:companyName)
I assume there is somewhere a flag to disable this restrictions, because there might be cases, like mine, where this standard functions are needed.
Kind Regards,
CarlHi Vladimir,
no it's not the same issue, because I am asking for a solution for this problem. There have to be ways to bypass this. Otherwise you can't use JPA properly. This is too much of a restriction!
Is there no possibility to change to another implementation than openSQL?
Regards,
Carl
Edited by: Carl Simon Heckmann on Feb 2, 2009 2:26 PM -
I've designed Calculator Program, used by String function
Hello Everyone,
I've designed Calculator Program, used by String function. U've any Feedback in this program, cantact me.
Thanks & Regards,
SABARI SARAVANAN M
Certified LabVIEW Associate Developer
Attachments:
calculator.vi 71 KBHi Jitendra,
Does the dump log shows that the cause is memory shortage?
Thanks and Best Regards,
Vikas Bittera.
**Points for useful answers** -
How to Use the language function for assignment and validation
Hi All,
If anyone can explain me in details with example ,how to use the language function for assignments and validations?
Thanks
ArnabHi Arnab,
The expression is checked only for the current MDM session.
If u login with the ABC language it will always show the ABC language no matter how many times u execute it.
Try connecting to the DM with the XYZ language.
It should go to the if part rather than else.
Hope it helps.
Thanks,
Minaz -
I lost my Iphone 3GS. My brother has given me his Iphone 4 now. We both use the same notebook to update and sync our phones. I would like to know how can i reconnect back to my account using the Iphone which was previous used by my brother.
If you are saying that you both have iCloud accounts and use the same icloud ID, then yes, the contacts will be deleted. The idea is that all devices using the same icloud ID are kept in sync. You need to use different IDs. You can keep the same iTunes ID so you can share the songs and apps. But use different icloud IDs.
-
When i use language for non-unicode [Russian] and i insert another language
when i use language for non-Unicode [Russian] and i insert another language. it transform to Russian.
i insert Thai language into MS access it transform to Russian type.i try to change anything,CharSet, sun.jnu.encoding.
but it doesn't have any effect.How can i insert Thai data into database and in database shown Thai data not another type.
Thank you for help.My English is not good,Sorrythat is a little-known known issue
Check this post:
http://myitforum.com/cs2/blogs/smslist/archive/2009/01/12/mssms-userlocale-in-mdt-sccm-also-changes-system-locale-9a532hdf.aspx
He details how to modify the ZTIConifgure.xml file. -
How to use Php a function in an insert transaction ?
Hi,
I want to insert a computed data (string) based on a date (dd-mm-aaaa hh:mm:ss).
The result must be AAAAMM Year+month without spaces.
So i tried this :
$ins_agenda->addColumn("aaaa_mm", "string", "POST", "date({date_debut_effective},'Ym')");
But it failed.
Is it possible to use Php fonction with an appropriated syntax ?
Thanks for your help. JM.I get this :
tNG_fields.getColumnValue:
Column date_debut_effective is not part of the current transaction
In fact, date_debut_effective is the form field name, deb_eve is the database field name (transaction name).
aaaa_mm is another database field in the same table, same transaction.
aaaa_mm should only be computed with deb_eve data.
When I use deb_eve as transaction field name in the trigger, the targeted database field (aaaa_mm) remain empty after the insert.
The logic should like this :
Form field (format datetime)
-> database X field deb_eve (same format datetime)
-> computed database X field aaaa_mm (format aaaamm or Ym)
I use this : $ins_agenda_previsionnel->addColumn("aaaa_mm", "STRING_TYPE", "CURRVAL", ""); to fill aaaa_mm field.
My code :
before trigger
// date de début effective vers date aaaamm
function Trigger_Custom_aaaamm(&$tNG) {
$date_field = $tNG->getColumnValue(deb_eve);
$tNG->setColumnValue("aaaa_mm", date($date_field,'Ym') );
insert transaction
// Make an insert transaction instance
$ins_agenda_previsionnel = new tNG_insert($conn_cnxWarh);
$tNGs->addTransaction($ins_agenda_previsionnel);
// Register triggers
$ins_agenda_previsionnel->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "");
$ins_agenda_previsionnel->registerTrigger("BEFORE", "Trigger_Custom_aaaamm", 98);
$ins_agenda_previsionnel->registerTrigger("AFTER", "Trigger_LinkTransactions3", 98);
$ins_agenda_previsionnel->registerTrigger("ERROR", "Trigger_LinkTransactions3", 98); //liste IRP
// Add columns
$ins_agenda_previsionnel->setTable("agenda_previsionnel");
$ins_agenda_previsionnel->addColumn("id_agent", "NUMERIC_TYPE", "VALUE", "{rsfiche_agent.id_agent}");
$ins_agenda_previsionnel->addColumn("aaaa_mm", "STRING_TYPE", "CURRVAL", "");
$ins_agenda_previsionnel->addColumn("titre", "STRING_TYPE", "VALUE", "ENTREE AGENT");
$ins_agenda_previsionnel->addColumn("evenement", "STRING_TYPE", "VALUE", "Entrée Agent {Vue_Visu.prenom} {Vue_Visu.nom_complet} ");
$ins_agenda_previsionnel->addColumn("deb_eve", "DATE_TYPE", "POST", "date_debut_effective");
$ins_agenda_previsionnel->addColumn("fin_eve", "DATE_TYPE", "VALUE", "{Vue_Visu.date_fin_contrat}");
$ins_agenda_previsionnel->addColumn("frequence", "STRING_TYPE", "VALUE", "1");
$ins_agenda_previsionnel->setPrimaryKey("id_agenda", "NUMERIC_TYPE"); -
Powershell use Connection String to query Database and write to Excel
Right now I have a powershell script that uses ODBC to query SQL Server 2008 / 2012 database and write to EXCEL
$excel = New-Object -Com Excel.Application
$excel.Visible = $True
$wb = $Excel.Workbooks.Add()
$ws = $wb.Worksheets.Item(1)
$ws.name = "GUP Download Activity"
$qt = $ws.QueryTables.Add("ODBC;DSN=$DSN;UID=$username;PWD=$password", $ws.Range("A1"), $SQL_Statement)
if ($qt.Refresh()){
$ws.Activate()
$ws.Select()
$excel.Rows.Item(1).HorizontalAlignment = $xlCenter
$excel.Rows.Item(1).VerticalAlignment = $xlTop
$excel.Rows.Item("1:1").Font.Name = "Calibri"
$excel.Rows.Item("1:1").Font.Size = 11
$excel.Rows.Item("1:1").Font.Bold = $true
$filename = "D:\Script\Reports\Status_$a.xlsx"
if (test-path $filename ) { rm $filename }
$wb.SaveAs($filename, $xlOpenXMLWorkbook) #save as an XML Workbook (xslx)
$wb.Saved = $True #flag it as being saved
$wb.Close() #close the document
$Excel.Quit() #and the instance of Excel
$wb = $Null #set all variables that point to Excel objects to null
$ws = $Null #makes sure Excel deflates
$Excel=$Null #let the air out
I would like to use connection string to query the database and write results to EXCEL, i.e.
$SQL_Statement = "SELECT ..."
$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "Server=10.10.10.10;Initial Catalog=mydatabase;User Id=$username;Password=$password;"
$conn.Open()
$cmd = New-Object System.Data.SqlClient.SqlCommand($SQL_Statement,$conn)
do{
try{
$rdr = $cmd.ExecuteReader()
while ($rdr.read()){
$sql_output += ,@($rdr.GetValue(0), $rdr.GetValue(1))
$transactionComplete = $true
catch{
$transactionComplete = $false
}until ($transactionComplete)
$conn.Close()
How would I read the columns and data for $sql_output into an EXCEL worksheet. Where do I find these tutorials?Hi Q.P.Waverly,
If you mean to export the data in $sql_output to excel document, please try to format the output with psobject:
$sql_output=@()
do{
try{
$rdr = $cmd.ExecuteReader()
while ($rdr.read()){
$sql_output+=New-Object PSObject -Property @{data1 = $rdr.GetValue(0);data2 =$rdr.GetValue(1)}
$transactionComplete = $true
catch{
$transactionComplete = $false
}until ($transactionComplete)
$conn.Close()
Then please try to use the cmdlet "Export-Csv" to export the data to excel like:
$sql_output | Export-Csv d:\data.csv
Or you can export to worksheet like:
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $true
$workbook = $excel.Workbooks.Add()
$sheet = $workbook.ActiveSheet
$counter = 0
$sql_output | ForEach-Object {
$counter++
$sheet.cells.Item($counter,1) = $_.data1$sheet.cells.Item($counter,2) = $_.data2}
Refer to:
PowerShell and Excel: Fast, Safe, and Reliable
If there is anything else regarding this issue, please feel free to post back.
Best Regards,
Anna Wang -
iph 4s, using windows 8; downloaded latest update 6 for iphone and iphone software update center could not be contacted or is not available; tried troubleshooting; removed other usb connections and restarted computer; still will not connect to iphone software update center; any suggestions?
I noticed the Windows Firewall Entry in the diagnostics, so I did get that part squared away...
Windows Firewall is on.
iTunes is enabled in Windows Firewall.
Connection attempt to Apple web site was successful.
Connection attempt to browsing iTunes Store was successful.
Connection attempt to purchasing from iTunes Store was successful.
Connection attempt to iPhone activation server was successful.
Connection attempt to firmware update server was successful.
Connection attempt to Gracenote server was successful.
Last successful iTunes Store access was 2013-11-07 17:52:33.
Still unable to detect the iPhone though. -
Cannot use php mail() function in leopard's localhost
<?php
$to = "[email protected]";
$subject = "test subject";
$message = "test message";
$from = "[email protected]";
$headers = "From: $from";
mail($to, $subject, $message, $headers)
?>
This code doesn't work on my localhost but when I uploaded it to my sever it run normaly. Then how can I use the mail function on my localhost to test it before I need to publish it to my serverHave you started the mail server on your machine?
By default PHP will try to use the local mail server to send the message. If you haven't started Postfix the message will go nowhere. -
My ipod has been disabled as I cant remember the passcode . When doing a restore on I Tunes it will only update and restore , the update doesnt work as the phone is locked and I need a passcode. I have tried the other way which is to hold the sleep/wake key and home key together for 10 seconds but as soon as you plug it inot the pc the ipod boots up so this method doesnt work either . Very close to usin it as a brick , any suggestions ?? Thank you
Disabled
Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
iOS: Forgot passcode or device disabled
If recovery mode does not work try DFU mode.
How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
For how to restore:
iTunes: Restoring iOS software
To restore from backup see:
iOS: Back up and restore your iOS device with iCloud or iTunes
If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
You can redownload most iTunes purchases by:
Downloading past purchases from the App Store, iBookstore, and iTunes Store
If problem what happens or does not happen and when in the instructions? When you successfully get the iPod in recovery mode and connect to computer iTunes should say it found an iPod in recovery mode.
Dry another cable
Next try on another computer.
Last
Make an appointment at the Genius Bar of an Apple store.
Apple Retail Store - Genius Bar -
Using ARD to verify DST Update and Office Update
I am trying to use ARD to verify which users have installed the Daylight Saving Time Update 1.0 on our network. Is there a way to verify this with a report? I know that I can send out Install Packages, but I just didn't want to do that for potentially only a few individuals. Plus I am not sure what type of disruption it would cause to everybody.
We do use exchange accounts so I understand we have to get the 11.3.3 Office 2004 update as well. I can verify this through Report, Software Version..., then select Entourage.
I am fairly new at ARD so any suggestions/help would be appreciated.
Thanks.We do use exchange accounts so I understand we have
to get the 11.3.3 Office 2004 update as well. I can
verify this through Report, Software Version...,
then select Entourage.
I know this is already marked as solved, but I thought I'd share anyway.
We noticed a few updates ago that not every application was effected by every update. After the 11.3.3 update, PowerPoint still lists version 11.3.2 in the Get Info window. Because of this, I've just started using this command:
ls -l /Applications/"Microsoft Office 2004"/"Updater Logs"/
The results for me are:
-rwxrwxrwx 1 admin staff 121208 Jun 23 2006 11.2.4 Update Log.txt
-rwxrwxrwx 1 admin staff 120324 Jul 31 2006 11.2.5 Update Log.txt
-rwxrwxrwx 1 admin staff 120498 Nov 9 14:56 11.3.0 Update Log.txt
-rwxrwxrwx 1 admin staff 120494 Jan 15 23:11 11.3.3 Update Log.txt
It's kind of a pain to go through the results (and I might just be a little paranoid) but it's helped.
I just wish they'd release these updates as packages instead of applications, but that's something else entirely.
Mac OS X (10.4.8) -
Using WSUS for Cluster Aware Updates and SCCM???
Can WSUS support SCCM and CAU(cluster aware update) from the same WSUS instance? E.G. If I have my SCCM infrastructure getting its patches from a server called SCCM01 lets say and the primary/central site is also on this box, can the WSUS instance on
this server support CAU or will that break SCCM? I ask because one of our admins did exactly this a few weeks ago and we end up having to reinstall WSUS. It could have been a coincidence but that WSUS instance had been running fine since it was built. Seems
kina strange it broke relatively quickly.
I've read plenty of sites that say to avoid meddling in the WSUS console once SCCM is installed but I can't find a specific technet article saying not to do this. I just built the 2012 environment and they're wanting to configure it the same way and I'm
refusing because I suspect it will break either SCCM 2012 or WSUS or both! Please if someone could point me in the right direction or offer some clarity I would very much appreciate it. So far all I've seen about CAU is that it does support SCCM and WSUS but
I can't find any documents saying what the repercussions of configuring CAU to use the same WSUS instance that SCCM uses. Thanks in advance. -KR.Correct, ConfigMgr is unaware of cluster updating or the WSUS capabilities around clustering.
Also correct that direct WSUS administration after WSUS is integrated with ConfigMgr is a bad thing. There is no specific article that says don't do "stuff" in the WSUS admin console but it is eluded to in the TechNet docs (http://technet.microsoft.com/en-us/library/gg712696.aspx) and
I do know that it is specifically unsupported. I also know from experience that it will/can cause issues.
Cluster patching with ConfigMgr can be done using multiple techniques including maintenance windows, Orchestrator, or other automation tools but there's nothing definitively built in
Jason | http://blog.configmgrftw.com | @jasonsandys -
How to use User defined Function in Update statement
Hi All,
I have written below update statement to update column based on value return by function. but it is not working. Could any one help me on this. This function will return only one value for each project.
thanks in advance.
UPDATE dg2.OD_PROJ_LOOKUP_TEMP o
SET Months_In_Stage_Cnt = select Months_In_Stage_Cnt_ret(o.project_id) from dual;
thanks
debhi,
CREATE FUNCTION fn_emp_ename (p_empno IN emp.empno%TYPE)
RETURN VARCHAR2
IS
v_ename emp.ename%TYPE;
BEGIN
SELECT ename
INTO v_ename
FROM emp
WHERE empno = p_empno;
RETURN v_ename;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
RETURN NULL;
WHEN OTHERS
THEN
RETURN NULL;
END fn_emp_ename;
SQL>
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
SQL> select fn_emp_ename (empno) as emp_name from emp;
EMP_NAME
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER
14 rows selected.
SQL> update emp
2 set ename= fn_emp_ename (7936)
3 where empno=7934;
1 row updated.
SQL> commit;
Commit complete.
SQL> select * from emp where empno=7934;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTN
7934 CLERK 7782 23-JAN-82 1300 1
SQL> i hope this helps .........
Thanks,
P Prakash
Edited by: prakash on Nov 17, 2011 11:52 PM -
I am using the email function in Apex, and it works fine with my email
address, but when I change it to an email other than mine, it doesn't work.
I am using this:
for c1 in (select cust_email
from demo_customers
where customer_id = :P201_CUSTOMER_ID) loop
if c1.cust_email is not null then
HTMLDB_MAIL.SEND(
P_TO => c1.cust_email,
P_FROM => c1.cust_email,
P_BODY => 'Your order has been received and '||chr(10)||
'will be processed shortly.',
P_SUBJ => 'Order Number '||:P201_ORDER_ID||' received.');
end if;
end loop;
Message was edited by:
PinnexCan you be more specific about the problem? Can't really understand much from your one-line question!
Edit:
By the time I posted, u had edited ur 1 liner into multiple liner...no offense!
Message was edited by:
Scorpio
Maybe you are looking for
-
Hi All, I have a multiprovider which is based on two cubes.There are some characterstics which are simliar in cubes like sales doc,item,ship_to,sold_to.The scenario is as follows:- The key figure on which I am reporting is from Cube2 and there is mix
-
How do I move a Muse page from one document to another?
I have a site that I built with Muse a year ago. I am currently building a new version of it (also in Muse). I want to be able to use a couple of the 'old' pages in the 'new' version. Is there a way I can copy a page and its assets from one Muse docu
-
Mozilla firefox 25.0 tab opens with error on URL res://ieframe.dll/unknownprotocol.htm#chrome-extension://kcnhkahnjcbndmmehfkdnkjomaanaooo/widget.html any idea? I believe this is a google voice extension but I do not have chrome installed on my PC Wi
-
Hello, I use a infoprovider with cumulative key figures. Unfortunately calendar year and fiscal year are different. SAP only offers 0CALQUARTER, but I need the quarter of the fiscal year. Just modifying the value of 0CALQUARTER does not help, because
-
Importing and Editing .MOV Files
Hello, I would like to know if After Effects can edit .MOV files or should these type files be converted to another format? I imported a .mov file to After Effects and although I can view the movie in the composition window. I don't see any other inf