小弟刚开始接触PHP没多长时间,想请教一下各位大神,
有一个数据表,
birthday 字段的内容是 1989-11-28
ageyear字段是 年
agemonth字段是 月
ageday字段是 日
想写个语句,读取birthday里的内容,分别写入到 年 月 日 这三个字段里。
这个语句杂写类?
都在一个数据表里
哪怕分别执行三次实现这个功能也行
哪个大哥帮忙给写一写
写个SQL语句或者是PHP执行文件都行,只要能实现这种功能就可以,谢谢谢谢。
还有就是想再请教一个SQL更新语句,更新某个表里指定的内容修改为其它内容,比如把一个字段里123里的2修改成3 ,谢谢了。
回复讨论(解决方案)
用一个select语句查询这个表 得到birthday表。。
$birthday=$row["birthaday"]
$array=explode("-",$birthday)
$year=$array[1]
$mon=$array[2]
$day=$array[3]
再用update 更新进去
用一个select语句查询这个表 得到birthday表。。
$birthday=$row["birthaday"]
$array=explode("-",$birthday)
$year=$array[1]
$mon=$array[2]
$day=$array[3]
再用update 更新进去
恩。这个方法倒是不错。但是具体应该怎么执行呢?是单独写一个PHP文件?并且新建一个表?
update 数据表 set ageyear=left(birthday ,4), agemonth=substring(birthday ,instr(birthday ,'-')+1,2), ageday=right(birthday ,2);
update tb set 字段=replace(字段,'2','3');
update 数据表 set ageyear=left(birthday ,4), agemonth=substring(birthday ,instr(birthday ,'-')+1,2), ageday=right(birthday ,2);
update tb set 字段=replace(字段,'2','3');
成功了,相当感谢,

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1
Easy-to-use and free code editor

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Chinese version
Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
