Sie sind auf Seite 1von 5

Trouble shooting- Documentation

1.Getting the MySQL query output in a file(cs ! from a remote client MySQL ser er mysql -u mysql"username -pmysql"pass#or$ --database $atabase"name -h remote"host"ip"a$$ress -ss -e "mySQL"query " | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > filename.cs %.Getting the MySQL query output in a file(cs ! from local MySQL ser er SELEC !"de"#$d,p"!du%t#name,qty &"!m !"de"s $nt! !ut&$le '/tmp/!"de"s'%s(' &$elds te"m$nated by ',' en%l!sed by '"' l$nes te"m$nated by '\n' &.Query to fin$ umber of $uplicates ro#s in a column sele%t %!lumn#name, %!unt)*+ % &"!m table g"!up by %!lumn#name ha($ng % > ,; '.( en if #e set the )* in the net#or+ configuration by typing ,setup,-chec+ing by typing ,ifconfig, #e are getting #rong ip a$$ress it is sho#ing only the loop bac+ a$$ress (1%.././.1! a+($ /et%/ sys%!n&$g/net-!".-s%"$pts/$&%&g-eth/ b+set 011 231 14stat$% !nb!!t4yes %+se"($%e net-!". "esta"t 0.Setting 1p 1S(23D(4)5( mo$e 6.ho# to $isplay contents of a file in php
echo file_get_contents( "filenme.php" ); or $file = fopen("r.txt", "r"); while (!feof($file)) { $line_of_text = fgets($file); echo $line_of_text."<br />"; } fclose($file); 7.how to turn on display errors in php go to php.ini file and turn display_errors=on

7.creating a $atabase from terminal mysqladm$n %"eate database#name -u "!!t -p 8.login into a $atabase $irectly from terminal mysql database#name -u "!!t -p 1/.chec+ing #hich $atabase currently #e are sele%t database)+; 11.creating a ne# user to a $atabase an$ granting all pri ilages g"ant all !n database#name'* t! use"#name5l!%alh!st $dent$&$ed by 'pass-!"d' 1%.T#o #ays to print $ata from a table as a tabular format a! -h$le)$"!-4mysql$#&et%h#ass!%)$"esult++ 6 e7t"a%t)$"!-+; e%h! "8t">"; e%h! "8td>"'$%and#name'"8/td>"; e%h! "8td>"'$%and#age'"8/td>"; e%h! "8td>"'$%and#state'"8/td>"; e%h! "8td>"'$%and#pa"ty'"8/td>"; e%h! "8/t">"; 9 mysqli"fetch"assoc -$ll &et%h ea%h "!- &"!m the table as a ass!%$at$(e a""ay &!" e7ample $"!-4a""ay)%and#name4>:"!shan:,%and#age 4>;/,'''''''+ the &un%t$!n e9tract -$ll t"eat the .ey as a (a"$able and the (alue !& ea%h .ey as the (alue !& the (a"$able &!" e7ample $%and#name4:"!shan: $%and#age4;/

b! e%h! <8table b!"de"4:,:>=; -h$le )$"!- 4 mysql#&et%h#ass!%)$"esult++ 6 e%h! <8t">=; &!"ea%h )$"!- as $(alue+ 6 e%h! <8td>= ' $(alue ' <8/td>=; 9 e%h! <8/t">=; 9 e%h! <8/table>=;

' mysqli"fetch"assoc -$ll &et%h ea%h "!- &"!m the table as a ass!%$at$(e a""ay &!" e7ample $"!-4a""ay)%and#name4>:"!shan:,%and#age 4>;/,'''''''+ &!" ea%h "!- &et%hed by mysqli"fetch"assoc -foreach -$ll p"$nt the (alue &!" ea%h .ey $n !ne "!&!" e7ample &!" the ab!(e "!- foreach -$ll p"$nt "!shan ;/ '''''''''''' 1&!referencing t#o tables >!u %an get $n&!"mat$!n &"!m m!"e than !ne table $n t-! -ays? 3e&e"en%e the $nd$($dual tables $n y!u" que"y and l$n. them temp!"a"$ly th"!ugh a %!mm!n &$eld' @!"mally A1BC the $nd$($dual tables $n y!u" que"y 1'!:o# to ie# the $etails of the table; Sh!- table status;//-$ll sh!- the deta$ls !& all tables $n a database sh!- table status -he"e name4:table#name:;//-$ll g$(e deta$ls !& a spe%$&$% table 10!Solution for the error <(22=2 1'0% (%&///!> 5annot a$$ or up$ate a chil$ ro#> a foreign +ey constraint fails < #hile creating a foriegn +ey using alter? mysql> SE &!"e$gn#.ey#%he%.s 4 /; mysql> //type the &!"$en .ey que"y mysql> SE &!"e$gn#.ey#%he%.s 4 ,;

16!(9ample for left @oin as #ell as group by an$ count functions %!ns$de" t-! tables AuserB table> i$ , E F ; H name Dl$%e 0!b Ca"!l$ne Ga($d Emma course , , E H )CILL+

AcourseB table> i$ , E F ; H name J KLH CSSF Aa(aS%"$pt 2J2 KySLL

count the number of stu$ents enrolle$ on each course>

SELEC %!u"se'name, C1IC )use"'name+ @31K M%!u"seM LE@ A1BC Muse"M 1C use"'%!u"se 4 %!u"se'$d N31I2 0> %!u"se'$d; 2esult course.name J KLH CSSF Aa(aS%"$pt 2J2 KySLL count(! E , / / ,

Je"e N31I2 0> ta.es ea%h %!u"se $d say ',' and g"!ups all use"'name)&"!m %!unt)+ &un%t$!n+ that mat%hes -$th th$s %!u"se $d ,)al$%e,b!b+ ---------->E E)%a"!l$ne+------------->, F)CILL+-------------->/ ;)CILL+-------------->/ H)da($d+--------------->, a&te" that C1IC )+ "etu"ns numbe" !& use"names &!" ea%h g"!up it #ill print the course name Ca a script-*:* e en if user.course D course.i$ fails for those too since #e ha e use$ L(ET C=)F(-h$%h mat%hes e(e"y ent"y $n the le&t table )use"+ "ega"dless !& any mat%h$ng ent"y $n the "$ght table)%!u"se !

1.!#hat is the benefit of using spl"autoloa$"register(! function;; spl#aut!l!ad#"eg$ste")&un%t$!n)$%lass+6 "equ$"e#!n%e '%lasses/' '$%lass' ''php'; 9+; $myClass = new MyClass(); Bn the e7ample, ab!(e, "KyClass" $s the name !& the %lass that y!u a"e t"y$ng t! $nstant$ate, 2J2 passes th$s name as a st"$ng t! spl_autoload_register(), -h$%h all!-s y!u t! p$%. up the (a"$able and use $t t! "$n%lude" the app"!p"$ate %lass/&$le' Ds a "esult, y!u d!n't spe%$&$%ally need t! $n%lude that %lass ($a an $n%lude/"equ$"e statement''' 17!Ghat is calle$ *D=(*:* $ata ob@ects! he PHP Data Objects )2G1+ e7tens$!n de&$nes a l$ght-e$ght, %!ns$stent $nte"&a%e &!" a%%ess$ng databases $n 2J2' Ea%h database d"$(e" that $mplements the 2G1 $nte"&a%e %an e7p!se databasespe%$&$% &eatu"es as "egula" e7tens$!n &un%t$!ns' C!te that y!u %ann!t pe"&!"m any database &un%t$!ns us$ng the 2G1 e7tens$!n by $tsel&; y!u must use a database-spe%$&$% 2G1 d"$(e" t! a%%ess a database se"(e"' 2G1 p"!($des a data-access abst"a%t$!n laye", -h$%h means that, "ega"dless !& -h$%h database y!u'"e us$ng, y!u use the same &un%t$!ns t! $ssue que"$es and &et%h data' 2G1 d!es not p"!($de a database abst"a%t$!n; $t d!esn't "e-"$te SLL !" emulate m$ss$ng &eatu"es' >!u sh!uld use a &ullbl!-n abst"a%t$!n laye" $& y!u need that &a%$l$ty'

Das könnte Ihnen auch gefallen