ããšãã°ãåºèã§ã¯ãã·ãªã¢ã«çªå·ãããŒã³ãŒãã§è£œåãéžæããããšã¯ãããŸãããããã®æå³ãç解ããããšã¯ãããŸãããé¢å¿ã®ãã補åã®ããããã£ã調ã¹ãŸãã ããšãã°ããµã€ãã®ã¡ã€ã³ããŒãžã§ãææ°ã®ãã¥ãŒã¹ã衚瀺ããå¿ èŠããããŸããææ°ã®ãã¥ãŒã¹ã¯ãããŒã¿ããŒã¹ïŒãªããžã§ã¯ãããŒã¿ã¢ãã«ïŒãããNewsã¯ã©ã¹ã®10åã®ãªããžã§ã¯ããäœææ¥ã§ãœãŒãããŠéžæããããšã«ãªããŸãã ãã®ãããªã¯ãšãªãå®è£ ããã«ã¯ããªããžã§ã¯ãã¢ãã«ã®æ©èœãèæ ®ããŠããšã³ãã£ãã£ãéžæããããã®æ¡ä»¶ïŒæ€çŽ¢æ¡ä»¶ïŒãèšè¿°ããããã®æè»ãªæ¹æ³ãå¿ èŠã§ãã æ¡ä»¶ã«åºã¥ããŠãæ¡ä»¶ãæºãããšã³ãã£ãã£ã®èå¥åã®ããŒã¿ããŒã¹ããçŽæ¥éžæããããã®SQLã³ãŒããäœæããå¿ èŠããããŸããèå¥åããããŸã-ãšã³ãã£ãã£ããããŸãã
ãªããžã§ã¯ãã¢ãããŒãã䜿çšããŠãæ€çŽ¢èªãäœæããŸãã éå±€ã¯ãè«çé¢æ°ããã®ä»ã®é¢æ°ãè¡šããªããžã§ã¯ãããäœæãããŸã;çè«çã«ã¯ãæ°åŠé¢æ°ãšããŠè§£éã§ããŸãã 以äžã¯ãããã¥ãŒã¹ãã¯ã©ã¹ã®ãšã³ãã£ãã£ãååŸããããã®æ¡ä»¶ã®äŸã§ãã 次ã®ããã«åŸ©å·åãããŸããå±æ§ãsys_nameãïŒQ :: AttribïŒãå€ãnewsãïŒQ :: CompïŒã«çããã¯ã©ã¹ïŒQ :: IsClassïŒã«å±ãããšã³ãã£ãã£ïŒQ :: EntityïŒãéžæããŸãã
$cond = Q::Entity( Q::IsClass( Q::Comp(Q::Attrib('sys_name'), '=', 'news') ) );
æ¡ä»¶ã¯ãã¯ãšãªã¯ãšãªãªããžã§ã¯ãã®äœæã«äœ¿çšãããŸãã Queryãªããžã§ã¯ãã¯SQLã³ãŒãã®æ¡ä»¶ã解éããExecuteïŒïŒã¡ãœãããåŒã³åºããããšãã«å®è¡ããŸãã ã¯ãšãªã®çµæã¯ãèŠã€ãã£ããšã³ãã£ãã£ã®é åã§ãããŸãã¯ãCounté¢æ°ã§æ¡ä»¶ãå§ãŸã£ãå Žåãçµæã¯æŽæ°ïŒæ¡ä»¶ãæºããããšã³ãã£ãã£ã®æ°ïŒã«ãªããŸãã ãšã³ãã£ãã£ã®æ€çŽ¢ã¯ãSQLã®LIMITãã©ã¡ãŒã¿ãŒã§è¡ãããããã«ãçªå·ã§å¶éãããªãã»ãããå®è¡ã§ããŸããå¶éã¯ãã¯ãšãªãäœæãããšãã®2çªç®ãš3çªç®ã®åŒæ°ããŸãã¯ã¯ãšãªãªããžã§ã¯ãã®SetCountïŒïŒããã³SetStartïŒïŒã¡ãœããã䜿çšããŠå®è¡ãããŸãã
// $cond 10 // (0) $q = new Query($cond, 10, 0); // . â Object $list = $q->Execute(); if (sizeof($list)>0){ echo $list[0]->getP('head')->getA('value'); // }
æ¡ä»¶ã¯ã¯ã©ã¹CondAttribãCondClassãCondCompãCondCountãCondEntityãCondIsExistãCondLinkãCondLogãCondNotExistãCondParamã®ãªããžã§ã¯ãããäœæãããŸãããæ°ããæŒç®åãšCond *ã¯ã©ã¹ãçŽæ¥äœ¿çšãã代ããã«æ§æãåçŽåããããã«ãéçQã¯ã©ã¹ã䜿çšãããŸããã¡ã¯ããªã¡ãœããïŒæ¡ä»¶ãªããžã§ã¯ããäœæãããŸãã
æ¡ä»¶ã«ã¯ãåŒæ°ïŒãšã³ãã£ãã£ãå±æ§ãé¢ä¿ïŒããšã³ãã£ãã£ã®å±æ§ãŸãã¯ããããã£ã®æç¡ããã§ãã¯ããé¢æ°ããšã³ãã£ãã£ãŸãã¯ãšã³ãã£ãã£èªäœã®ããããã£ã®æ°ãã«ãŠã³ãããé¢æ°ãæ¬åŒ§ã®åœ¹å²ãæããè«çé¢æ°Orããã³Andãããã³å±æ§å€ãæ¯èŒããé¢æ°ãå«ãŸããŸããŸãã¯ãæäœ '='ã '>'ã '<'ã '<='ã '> ='ã '<>'ã 'like'ã䜿çšããæ°éèšç®é¢æ°ã®çµæã
SQLãšã¯ç°ãªãããã§ããããå Žåãéžæããå ŽæïŒããŒãã«ããïŒãæå®ããå¿ èŠããçµæã®çµåãã°ã«ãŒãåãå¿ èŠãããŸããã ã¯ãšãªã§ã¯ãæ¡ä»¶ã®å©ããåããŠãåã«éžæãããã®ã瀺ãããŸãã ãªããžã§ã¯ãã¢ãã«ã§ã¯çµ¶å¯Ÿã«ãã¹ãŠããªããžã§ã¯ãã§ããããããªããžã§ã¯ããé€ããŠéžæãããã®ã¯ãªãããªããžã§ã¯ããæ€çŽ¢ãã代ããã«ãæ¡ä»¶ãæºãããªããžã§ã¯ãã®æ°ãèŠã€ããããšãå¯äžã®æ¹æ³ã§ãã ãããã£ãŠãæ¡ä»¶ã¯åžžã«ãšã³ãã£ãã£åŒæ°ãŸãã¯ãšã³ãã£ãã£ã«ãŠã³ãé¢æ°ã§å§ãŸããŸãã
// - $cond1 = Q::Entity( ); // - $cond2 = Q::Count(Q::Entity( ));
æåã®ã±ãŒã¹ã§ã¯ããã¡ãããã¯ãšãªã¯ãšãªã§å¿ èŠãªãšã³ãã£ãã£ã®æ°ã«å¶éããªãå Žåããªããžã§ã¯ãã¢ãã«ã®ãã¹ãŠã®ãšã³ãã£ãã£ïŒãã¹ãŠã®ãªããžã§ã¯ããã¯ã©ã¹ãããã³é¢ä¿ïŒãå«ãé åãè¿ãããŸãã 2çªç®ã®å Žåãæ°å€ãè¿ãããŸã-ãšã³ãã£ãã£ã®åèšæ°ã
絶察ã«ãã¹ãŠã®ãšã³ãã£ãã£ã«é¢å¿ãããããšã¯ãã£ãã«ãªãããããšã³ãã£ãã£ã®åŒæ°åŒæ°æ¡ä»¶Q ::ãšã³ãã£ãã£ïŒ$ condïŒã¯æ¡ä»¶$ condã«ãã£ãŠè£å®ããããã£ã«ã¿ãŒãšãåŒã°ããŸãã æ¡ä»¶ãç¶ç¶ãããã®ããã«ãç®çã®ãšã³ãã£ãã£ã«å«ããå¿ èŠãããå±æ§ãšããããã£ã決å®ããŸããã...ãæã€ãšã³ãã£ãã£ã
å±æ§
ãšã³ãã£ãã£å±æ§ã®å€ã«æ¡ä»¶ãèšå®ã§ããŸãã ãããè¡ãã«ã¯ãå±æ§Q :: Attribã瀺ãåŒæ°åŒæ°ãšæ¯èŒé¢æ°Q :: Compã䜿çšããŸãã 次ã®æ¡ä»¶ã¯ããsys_nameå±æ§ããªã³ã¯å€ãšçãããšã³ãã£ãã£ããæå³ããŸã
$cond = Q::Entity( Q::Comp(Q::Attrib('sys_name'),'=','link') );
ãšã³ãã£ãã£ã®å€ãŸãã¯äžè¬æ¡ä»¶ã®ãã§ãã¯ããããŸããªå Žåãè«çé¢æ°ãANDãããã³ãORãïŒQ :: LogAndããã³Q :: LogOrïŒã§æ¡ä»¶ãè£å®ã§ããŸãã è«çé¢æ°ãANDãããã³ãORãã¯ããã¹ãã®è€éãªæ¡ä»¶ãäœæã§ãããã©ã±ããã®åœ¹å²ãæãããŸãã
次ã®æ¡ä»¶ã®ã¯ãšãªã¯ãsys_nameå±æ§ããªã³ã¯å€ãšçããããsys_nameå±æ§ãã©ãã«å€ãšçãããis_defineå±æ§ã0ã§ãããšã³ãã£ãã£ãè¿ããŸãã
$cond = Q::Entity( Q::LogOr( Q::Comp(Q::Attrib('sys_name'),'=','link'), Q::LogAnd( Q::Comp(Q::Attrib('sys_name'),'=','label'), Q::Comp(Q::Attrib('is_define'),'=',0) ) ) );
åã®èšäºã§äœæã«ã€ããŠèª¬æãããªããžã§ã¯ãã¢ãã«ã§ã¯ãã¯ã©ã¹ãšãªã³ã¯ã¯sys_nameå±æ§ãæã£ãŠãããããäžèšã®æ¡ä»¶ã®çµæã¯ããªã³ã¯ã¯ã©ã¹ãšãããããã£ãå®çŸ©ããªãã·ã¹ãã åã©ãã«ãæã€ãªã³ã¯ã«ãªããŸãã çµæã¯ãç°çš®ãšã³ãã£ãã£ã«ãªããŸãã äžããããæ¡ä»¶ãå®éã«é©çšãããå¯èœæ§ã¯äœãããæ€çŽ¢ã«ããããšã³ãã£ãã£ã®ã¿ã€ãã«ç¡é¢å¿ã§ããããšããã瀺ããŠããŸãããæ¡ä»¶ã¯å€ãæ¯èŒãããå±æ§ã®ååšãæ確ã«ããªãããšã«æ³šæããŠãã ããã æ€çŽ¢ã¯ã人ãšã»ãŒåãæ¹æ³ã§å®è¡ãããŸãã ããšãã°ãã©ã³ããæ¥æ²¡ããã©ã¯ã¿ãŒãããŒã«ãè¡æ¶²ãçä¹³ãCCCPãã©ã°ãªã©ãããŸããŸãªçš®é¡ã®ãªããžã§ã¯ãã®äžã§èµ€ã§ãããã¹ãŠã®ãã®ãèŠã€ããã«ã¯ãåé¡ãªãæ€çŽ¢ãå®è¡ããŸããäž»ãªãã®ã¯èµ€ã§ãã
å€ã§ã¯ãªããã©ã¡ãŒã¿ãŒ
å±æ§ãæ¯èŒããã¹ã«ã©ãŒå€ã®ä»£ããã«ãQ :: Paramãã©ã¡ãŒã¿ãŒãQ :: Compæ¯èŒé¢æ°ã§äœ¿çšã§ããŸããããã«ãããçæãããèŠæ±ã®åŸã§ããã©ã¡ãŒã¿ãŒå€ãèšå®ã§ããŸãã ãããã£ãŠã1ã€ã®ã¯ãšãªãè€æ°å䜿çšããŠããã©ã¡ãŒã¿ã®å€ãåå²ãåœãŠããå¯èœæ§ããããŸãã
$cond = Q::Entity( Q::Comp(Q::Attrib('sys_name'),'=', Q::Param('par1')) ); // $q = new Query($cond); // $q->SetValue('par1', 'news'); // $list1 = $q->Execute(); // $q->SetValue('par1', 'name'); // $list2 = $q->Execute();
å±æ§å€ãæ¯èŒããããšã«å ããŠãé¢æ°function Q :: IsExistïŒïŒã«ãã£ãŠããããã®ååšã«æ¡ä»¶ãåçŽã«çœ®ãããšãã§ããŸãã 次ã®æ¡ä»¶ã¯ãå€å±æ§ãæã€ãšã³ãã£ãã£ãå®çŸ©ããŸããçµæã¯ãæååãšæ°åã®ãã¹ãŠã®ãªããžã§ã¯ãã«ãªããŸãã
$cond = Q::Entity( Q::IsExist(Q::Attrib('value')) );
ããããã£
ãœãŒãã«é¢ããŠã¯å±æ§ã«æ»ãããšã³ãã£ãã£ã®ããããã£ã®æ¡ä»¶ã«ã€ããŠèª¬æããŸãã ããããã£ã¯ãæ¥ç¶ãšãæ¥ç¶ã確ç«ãããšã³ãã£ãã£ã®çµã¿åããã§ãã ã¯ãšãªã®æ¡ä»¶ã¯ãããããã£ã®äžåš/ååšããŸãã¯ãšã³ãã£ãã£ã®ããããã£ã®æ°ã«åçŽã«çœ®ãããšãã§ããŸãã ããããæãèå³æ·±ãã®ã¯ãããããã£ããªããžã§ã¯ãïŒç¹°ãè¿ãïŒã§ãããããæ¥ç¶èªäœãŸãã¯æ¥ç¶ã確ç«ããããšã³ãã£ãã£ã®å±æ§ãšããããã£ã«æ¡ä»¶ãèšå®ã§ããããšã§ãã èããŠã¿ãŠãã ãããæ¥ç¶ãšæ¥ç¶ãè¡ããããªããžã§ã¯ãã¯ãå±æ§ãšããããã£ã§æãéèŠãªæ¡ä»¶ãç®çã®ãšã³ãã£ãã£ãšåãã«ãªãå¯èœæ§ãããããããã¹ãŠãå«ãæ¡ä»¶ãäœæã§ããŸãã ããšãã°ãç¹å®ã®ããããã£ãæã€ãšã³ãã£ãã£ãæ€çŽ¢ã§ããŸããããããã£ã§ãããªããžã§ã¯ãã«ã¯ãªããžã§ã¯ããšã®æ¥ç¶ïŒããããã£ïŒãå¿ èŠã§ããããªããžã§ã¯ãã«ã¯ç¹å®ã®ããã¹ããå«ãvalueå±æ§ãå¿ èŠã§ãã ããããã¹ãŠãæ¡ä»¶ã«ãããšãç¹ã«ã·ã¹ãã åãã©ã®ãããªçš®é¡ã®ããããã£ã§ããããæå®ããããšããã§ããŸããã æ€çŽ¢ã¯ãæ¡ä»¶ããããã£ãŠãããã®ã«å¯ŸããŠã®ã¿åäœããŸãã äžè¬çã«ãæœè±¡æ§ãæ±çšæ§ãæè»æ§ã
ããã§ã¯ãå¿ èŠãªãšã³ãã£ãã£ã®ããããã£ã®ååšããã§ãã¯ããæ¡ä»¶ããå§ããŸãããã å®éãæ¡ä»¶ã§ããããã£ãæå®ãããšããäºå®ã«ãã£ãŠããããã£ã®ååšã決ãŸããããæ¡ä»¶é¢æ°Q :: IsExistã䜿çšããå¿ èŠã¯ãããŸããã
$cond = Q::Entity( Q::Property( ) );
åãããšïŒ
$cond = Q::Entity( Q::IsExist(Q::Property()) );
äžèšã®æ¡ä»¶ã¯ããããã£ã®ååšã決å®ããæå®ãããŠããªããã®ãããããããã®æ¡ä»¶ã§ã®ã¯ãšãªã¯ãå°ãªããšã1ã€ã®ããããã£ãæã€ãã¹ãŠã®ãšã³ãã£ãã£ã«ãªããŸããã€ãŸãããããããã£ãæã€ãšã³ãã£ãã£ãã§ãã
éã¯ãããããã£ããªãããšã確èªããŠããŸãã ããããã£ããªãããšãå€æããã«ã¯ãQ :: NotExistæ¡ä»¶é¢æ°ã䜿çšããŸãã 以äžã®æ¡ä»¶ã®çµæã¯ãããããã£ãæããªããã¹ãŠã®ãšã³ãã£ãã£ã«ãªããŸãã
$cond = Q::Entity( Q::NotExist(Q::Property()) );
ç¹å®ã®ããããã£ã調æŽããæ¹æ³ã¯ïŒ Q ::ããããã£ïŒ$ link_condã$ entity_condïŒã«ã¯ãæ¥ç¶ã®æ¡ä»¶ãšæ¥ç¶ã確ç«ããããšã³ãã£ãã£ã®æ¡ä»¶ããããã決å®ãã2ã€ã®åŒæ°ããããŸãã ç¹°ãè¿ããŸãããéä¿¡ããªããžã§ã¯ããªã®ã§ããã®æ¡ä»¶ã¯ãšã³ãã£ãã£ã®å ŽåãšãŸã£ããåãã§ãã ããšãã°ãå±æ§æ¡ä»¶ã
次ã®æ¡ä»¶ã¯ãããããã£ã®é¢ä¿ã«å±æ§æ¡ä»¶ã䜿çšããŸãã ãã®æ¡ä»¶ã§ã®ã¯ãšãªã¯ãè€æ°ã®ããããã£ïŒãµã€ãº= 0ã¯è€æ°ãæå³ããŸãïŒãæã€ãšã³ãã£ãã£ãè¿ãããã¥ãŒã¹ã®ã¿ããããæã¡ãŸãã ããæ£ç¢ºã«ã¯ããµã€ãºå±æ§ããŒãã«çããæ¥ç¶ã¯ãã³ã¡ã³ããå®çŸ©ãããã¥ãŒã¹ã¯ã©ã¹ã«ãããæåã®ãã¥ãŒã¹ã«ã¯ã³ã¡ã³ãã2ã€ããã2çªç®ã®ãã¥ãŒã¹ã«ã¯ã³ã¡ã³ãããããŸããïŒåã®èšäºã®å³ãåç §ïŒã
$cond = Q::Entity( Q::Property( Q::Comp(Q::Attrib('size'),'=',0)) );
次ã«ããªã¬ãŒã·ã§ã³ã·ãããäœæããããšã³ãã£ãã£ã«æ¡ä»¶ãè¿œå ããŸãããªã¬ãŒã·ã§ã³ã·ãããäœæããããšã³ãã£ãã£ã®ããããã£ã«æ¡ä»¶ãèšå®ããŸãã 次ã®æ¡ä»¶ã¯ãè€æ°ã®ããããã£ãæã€ãšã³ãã£ãã£ãè¿ããŸããããããã£ã§ãããšã³ãã£ãã£ã¯ãããããã£ãæå®ããã«ç¬èªã®ããããã£ãæã¡ãŸãããå€å±æ§ã«ãFirstããšããããã¹ãã®ãã©ã°ã¡ã³ããå«ãŸãããšã³ãã£ãã£ã«é¢é£ä»ããããŸãã æ¡ä»¶ã¯æœè±¡çã§ããããšãå€æããŸããã ãã¥ãŒã¹ãªããžã§ã¯ãã«ã¯ã³ã¡ã³ããããããã®ã¿ã€ãã«ã¯ãæåããšããåèªã§å§ãŸããããå®éã«ã¯æåã®ãã¥ãŒã¹ã«ãªããŸãã ãã¥ãŒã¹é ç®ãšè§£èª¬ã®é¢ä¿ã¯ãæ¡ä»¶ã«ã¡ããã©åã
$cond = Q::Entity( Q::Property( Q::Comp(Q::Attrib('size'),'=',0), // Q::Entity( // , Q::Property( null, // Q::Entity(Q::Comp(Q::Attrib('value'),'like','%%')) ) ) ) );
ããããã£ã®æ°ãã«ãŠã³ãããæ¡ä»¶ã®äŸã瀺ããŸãããã 次ã®æ¡ä»¶ã¯ã4ã€ä»¥äžã®ããããã£ãæã€ãšã³ãã£ãã£ãè¿ããŸãã 圌ãã¯æåã®ãã¥ãŒã¹ãšã¯ã©ã¹ã®ã«ããŽãªã«ãªããŸãã ãã®ãã¥ãŒã¹ã«ã¯ãã«ããŽãªãèŠåºããããã¹ããããã³2ã€ã®ã³ã¡ã³ããžã®ãªã³ã¯ããããåèš5ã€ã®ããããã£ããããŸãã ã«ããŽãªã¯ã©ã¹ã«ã¯ãååã説æãããã³ãªããžã§ã¯ãã®ããããã£ãå®çŸ©ãã4ã€ã®é¢ä¿ïŒåèš6ïŒããããŸãããã®æ¡ä»¶ã§ã¯ãèæ ®ããé¢ä¿ãæå®ããŸããã§ããã
$cond = Q::Entity( Q::Comp(Q::Count(Q::Property()), '>', 4) );
ããããã£ã«æ¡ä»¶ãè¿œå ããããšãå¶éãããã®ã¯ãããŸãã;ç®çã®ãšã³ãã£ãã£ã§ããããã£ã®åœ¹å²ãæãããšã³ãã£ãã£ã§ããããã£ã«ãŠã³ããå®è¡ããããšãã§ããŸãã
æ¬è³ªã§ããæ¬è³ª
å®éã«ã¯ãä»ã®ãšã³ãã£ãã£ã®ããããã£ã§ãããšã³ãã£ãã£ãæ€çŽ¢ããããšããã°ãã°å¿ èŠã§ãã ããšãã°ãç¹å®ã®ãã¥ãŒã¹ã¢ã€ãã ã«å±ããã³ã¡ã³ããæ€çŽ¢ããŸãã ãããã®ç®çã®ããã«ãããããã£åŒæ°åŒæ°ãšåæ§ã«æ¡ä»¶åŒæ°Q :: IsPropertyã䜿çšãããŸãããå¯äžã®éãã¯ãé¢ä¿ãšé¢ä¿ãææãããšã³ãã£ãã£ãå®çŸ©ããããšã§ãã ããã§ãªããã°ããã¹ãŠãåãã§ã-ã³ãã¥ãã±ãŒã·ã§ã³ã®æ¡ä»¶ãæ¬è³ªã®æ¡ä»¶ã å¿ èŠãªãšã³ãã£ãã£ãåç §ãããšã³ãã£ãã£ã®æ°ãèšç®ããå°ãªããšã2人ã®ææè ãå¿ èŠã§ãããšããæ¡ä»¶ãèšå®ããããšãã§ããŸãã
$cond = Q::Entity( Q::Comp(Q::Count(Q::IsProperty()), '>=', 2) );
æå®ãããæ¡ä»¶ã¯ãã¯ã©ã¹ãstringãããlong_stringãããcategoryããããã³ãEventsããšããååã®ã«ãŒãã«ããŽãªã®ãªããžã§ã¯ããè¿ããŸããããããã¹ãŠã®ãšã³ãã£ãã£ã«ã¯è€æ°ã®ææè ãããŸãã
ã¯ã©ã¹ã¡ã³ããŒã·ãã
å¥ã®éèŠã§ãã䜿çšãããæ¡ä»¶ã¯ãQ :: IsClassã¯ã©ã¹ã«å±ããŠããããšã§ãã ã¯ã©ã¹ã«å±ããããšã¯å®éã«ã¯ãªããžã§ã¯ãã®ããããã£ã§ããããã§ãã¯ããããã®ç¹å¥ãªæ¹æ³ãå¿ èŠã§ãã ç¶æ¿ã®éå±€ãèæ ®ããå¿ èŠããããŸããã€ãŸããã¯ã©ã¹ã¡ã³ãã·ããã®æ€èšŒã¯ãæ¥ç¶ã確ç«ããããšã³ãã£ãã£ã®éåžžã®æ€èšŒã«èŠçŽãããŸããã ããšãã°ããã¥ãŒã¹ãªããžã§ã¯ãã¯ã¯ã©ã¹ãnewsãã«å±ããŸãããã¯ã©ã¹ãcontentãããã³åºæ¬ã¯ã©ã¹ãidãã«ãå±ããŸãã 以äžã®æ¡ä»¶ã¯ãã¹ãŠã®ã³ã¡ã³ããè¿ããŸãã
$cond = Q::Entity( Q::IsClass( Q::Comp(Q::Attrib('sys_name'), '=', 'comment') ) );
ã¯ã©ã¹ã¯ãªããžã§ã¯ãã§ãããããããšã³ãã£ãã£ã ãã§ãªãã¯ã©ã¹ã®æ¡ä»¶ã調æŽã§ããŸããå±æ§ãšããããã£ã確èªããŠãã ããã
Q :: LogAndããã³Q :: LogOrè«çé¢æ°ã®äœ¿çšã¯ãå±æ§å€ãæ¯èŒããããšã«ãã£ãŠã®ã¿å®èšŒãããããããã£Q :: PropertyãQ :: IsPropertyãã¯ã©ã¹Q :: IsClassããã³Qé¢æ°ã«å±ããæ¡ä»¶åŒæ°ãå«ããããšãã§ããŸãã :: IsExistããã³Q ::å¿ èŠãªæè»æ§ãæäŸããNotExistã
ä»åã
ãœãŒããªãã®æ€çŽ¢ã¯è¯ããããŸããã 䞊ã¹æ¿ãã䜿çšãããšãé¢é£ãããããã¯ã人æ°ã®ãã補åãªã©ãèŠã€ããŠé©çšãããµã€ãã®ã¡ã€ã³ããŒãžã§äººæ°ã®ããã³ã³ãã³ããäœæã§ããŸãã ããããæ¡ä»¶ããšã³ãã£ãã£ã®æ§é ã«ã€ããŠäœãæå®ããªãå Žåã«ãæ¡ä»¶ã®èãããããã¹ãŠã®ããªã¢ã³ããèæ ®ããŠãå¿ èŠãªãšã³ãã£ãã£ããœãŒãããæ¹æ³ã¯ïŒ å®éããœãŒãã®å®çŸ©ã¯éåžžã«åçŽã§ãããæ€çŽ¢SQLã¯ãšãªã®å®è¡æã«DBMSã§çŽæ¥å®è¡ãããŸãã
åœç¶ãã¹ã«ã©ãŒå€-å±æ§å€ã§ãœãŒãã§ããŸãã 䞊ã¹æ¿ããªãã·ã§ã³ã¯ãQ :: Attribå±æ§ã®æ¡ä»¶åŒæ°åŒæ°ã§æå®ãããŸãã ãããã£ãŠã䞊ã¹æ¿ããããå±æ§ã®å®çŸ©ãšäžŠã¹æ¿ããã©ã¡ãŒã¿ãŒïŒéé ãŸãã¯æé ã䞊ã¹æ¿ãé åº-䞊ã¹æ¿ãå¯èœãªå±æ§ãè€æ°ããå Žåã¯ã䞊ã¹æ¿ãé åºãæå®ã§ããŸãïŒãããã³å¿ èŠãªãšã³ãã£ãã£ã«ååšããå±æ§ã®æ¡ä»¶ãçµåãããŸãã
ç®çã®ãšã³ãã£ãã£ã«å¿ ãããå±ããªãå±æ§ã§ãœãŒãã§ããŸããå°ãªããšããç®çã®ãšã³ãã£ãã£ãšã®äžé£ã®ãªã¬ãŒã·ã§ã³ã·ããã«éæ¥çã«é¢é£ä»ããããŠãããšã³ãã£ãã£ã®å±æ§ã§ãœãŒãã§ããŸãã å±æ§ã®é¢ä¿ã¯ãããããã£ã§ãããªã¬ãŒã·ã§ã³ãšãªããžã§ã¯ãã«èšå®ã§ããããšãèŠããŠããŸããïŒ ãã®ãããå±æ§ã§äžŠã¹æ¿ããããšãã§ããŸãã ãµã€ãäžã®ãã¥ãŒã¹ã¯ãäœææ¥ãšãã¥ãŒã¹ã®èè ã®è©äŸ¡ã«ãã£ãŠåæã«ãœãŒãã§ããããšãããããŸããã ãŸãã¯ãè³Œå ¥ãã補åããè³Œå ¥ããåºèã®ååã§äžŠã¹æ¿ãããããªãã®ã§ãã補åã«çŽæ¥é¢ä¿ã®ãªãããããã£ã§äžŠã¹æ¿ããŸãã
çè«çã«ã¯ããšã³ãã£ãã£ã®ããããã£ã®æ°ãããšãã°ãã¥ãŒã¹ã®ã³ã¡ã³ãã®æ°ã§ãœãŒãããããšã¯å¯èœã§ãããäžæçã«ãã®æ©èœã¯å®è£ ãããŠããŸããã
ãŸããå±æ§ïŒãã®ååïŒã¯äžŠã¹æ¿ããã©ã¡ãŒã¿ãŒã§æå®ãããŸãããåæã«ãå±æ§å€ã®åã«ã€ããŠã®èª¬æã¯å¿ èŠãããŸããã ç¹ã«ãvalueå±æ§ã¯ç°ãªãã¯ã©ã¹ã®ãªããžã§ã¯ãã«ååšããæãéèŠãªããšã«ã¯ãç°ãªãã¯ã©ã¹ã®å€ã®ã¿ã€ãã«éãããããŸãã ç°ãªãé·ããæŽæ°ãå®æ°ã®æååã ãã ãããã®ãããªç¶æ³ã§ãããœãŒãã¯æ©èœããŸãã 次ã®æ¡ä»¶ã¯ãvalueå±æ§ãæã€ãªããžã§ã¯ãã®ãœãŒãããããªã¹ããè¿ããŸãã ãœãŒãã¯ãå€å±æ§ã«åŸã£ãŠæé ã§è¡ãããŸãã 2çªç®ã®åŒæ°ïŒtrueïŒã¯ãã®å±æ§ã«ãããœãŒãã決å®ãã3çªç®ïŒ1ïŒ-ãœãŒãé åºïŒããã€ãã®ãœãŒãå¯èœãªå±æ§ã«é¢é£ïŒããã³æåŸã®å±æ§ãœãŒãã¿ã€ãïŒfalse-æé ãtrue-éé ïŒ
$cond = Q::Entity( Q::IsExist(Q::Attrib('value', null, true, 1, false)) ); // $q = new Query($cond,0,0); $list = $q->Execute();
ãããã«
æ€çŽ¢çšèªãäœæããããã®ææ¡ãããã¢ãããŒãã¯è€éã«æãããããããŸããããããã¯SQLããã³ããã°ã©ãã³ã°èšèªã§è¡ãããŠããããã«ãæ¡ä»¶ã®æååèšè¿°ã«ãã¹ãŠæ £ããŠããããã§ãã ãªããžã§ã¯ãã¢ãããŒãã¯ã第äžã«ãããã°ã©ã åæãšSQLã¯ãšãªã®èªåçæã«äŸ¿å©ã§ãã第äºã«ãæå³ã®ããGUIã€ã³ã¿ãŒãã§ã€ã¹ãç°¡åã«äœæã§ããããã«ãªããŸãã
ããã«å€§ããªæžå¿µäºé ã¯ãããã©ãŒãã³ã¹ã®åé¡ãšããããã®éåžžã«æè»ãªæ¡ä»¶ããçããSQLã¯ãšãªã§ãã èŠæ±ã¯ããã»ã©æããã®ã§ã¯ãããŸããããè€æ°ã®LEFT JOIN-nov sinãä»ã®ãã¶ã€ã³ã䜿çšããããšã«ãããæè»æ§ãå®çŸããããšã¯å°é£ã§ãã
ãããžã§ã¯ããµã€ãïŒ boolive.ru
UPD 1幎åŸã ãªã¬ãŒã·ã§ãã«DBMSã®Object DBã®èšäºã§ãããŒã¿ã¢ãã«ã«é¢ããäœæ¥ã®çµæãç¥ãããšãææ¡ããŸãã
ãããžã§ã¯ãã®éçºã¯å¥ã®æ¹æ³ã§è¡ãããã·ã³ãã«ãã®éèŠæ§ãèªèããŸãã:)