<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[TNF : Tatter Network Foundation forum - componenet에서 function 추가는 어찌 하나요???]]></title>
		<link>http://forum.tattersite.com/ko/viewtopic.php?id=5758</link>
		<description><![CDATA[componenet에서 function 추가는 어찌 하나요??? 의 최근 RSS 글들.]]></description>
		<lastBuildDate>Mon, 09 Jun 2008 11:33:55 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[componenet에서 function 추가는 어찌 하나요???]]></title>
			<link>http://forum.tattersite.com/ko/viewtopic.php?pid=27787#p27787</link>
			<description><![CDATA[<p>OS : Windows2000 Server SP4<br />APM6 (Apache2.2.8 + PHP5.2.5 + MySQL5.0.51a) &lt;- Apache + PHP만 사용.<br />DB : MySQL4.1.22<br />Textcube : 1.6.3 확장판</p><p>위 환경에서 다중 블로그 사용중입니다.</p><p>대표블로그의 표지에 관리자가 올린 공지 글을 작성 일자에 상관없이 상단에 노출 시킬려고 이리저리 찾아보던중...</p><p>&quot;MT_Meta_RecentPS_Default&quot; 라는 플러그인에서 최근 글 리스트를 조회하더라구요.</p><p>그리고 플러그인에서는</p><p>[Textcube_Home]/components/Textcube.Model.Paging.php 소스에 있는 </p><p>&quot;fetchWithPaging&quot; 라는 function을 호출해서 사용하던데요.</p><br /><p>물론, 고수님들은 이미 너무 잘 알고 계시겠지만....php 첨하는 초보에게는 나름 힘든 여정이었네여^^;;;;</p><p>암튼, 그리하여 플러그인에서 날리는 쿼리를 제가 만든 쿼리로 대체해서 조회하니...</p><p>에러가 발생해서 컴포넌트 소스를 나름 뜯어보니....</p><p>전체 카운트 해오는 쿼리가 플러그인에서 날리는 쿼리의 from 절 이하는 그대로 따와서 select 절을 count(*)로 대체해서 전체 건수를 구하던데여..... 이부분에서 에러가 나더라구요.</p><p>잔머리를 살포시 굴려 동일한 function을 하나 더 만들고 count 부분의 쿼리만 살포시 바꿔주면 될줄 알았는데...</p><p>이것두 에러가 나네여...</p><p>컴포넌트에서 function을 추가하면 달리 해줘야 하는게 있는지여???</p><br /><br /><p>ps - 새로 던져줄려고 하는 쿼리입니다.</p><p>select<br />e.blogid, e.id, e.userid, e.title<br />, e.content, e.slogan, e.category, e.published, e.contentFormatter /*, c.label*/<br />from (<br />&nbsp; &nbsp; (<br />&nbsp; &nbsp; &nbsp; &nbsp; select<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blogid, id, userid, title<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , content, slogan, category, published, contentFormatter, &#039;0&#039; as aaa<br />&nbsp; &nbsp; &nbsp; &nbsp; from tc_entries<br />&nbsp; &nbsp; &nbsp; &nbsp; where blogid = &#039;1&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and category = &#039;-2&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and visibility = &#039;2&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; order by published desc<br />&nbsp; &nbsp; )<br />&nbsp; &nbsp; union<br />&nbsp; &nbsp; (<br />&nbsp; &nbsp; &nbsp; &nbsp; select<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blogid, id, userid, title<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , content, slogan, category, published, contentFormatter, &#039;1&#039; as aaa<br />&nbsp; &nbsp; &nbsp; &nbsp; from tc_entries<br />&nbsp; &nbsp; &nbsp; &nbsp; where category &lt;&gt; &#039;-2&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and visibility = &#039;2&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and blogid &lt;&gt; &#039;1&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; order by published desc<br />&nbsp; &nbsp; )<br />&nbsp; &nbsp; order by aaa, published desc<br />) e LEFT JOIN tc_Categories c ON e.blogid = c.blogid AND e.category = c.id</p><br /><br /><br /><br /><p>ps2 - 새로 생성하려는 function 입니다.<br />/*<br /> * 기존에 있는 fetchWithPaging function에서 이름만 바꾸고 전체 카운트 구하는 쿼리만 변경한 function<br /> */<br />function fetchWithPagingForCoverByPark($sql, $page, $count, $url = null, $prefix = &#039;?page=&#039;, $countItem = null) {<br />&nbsp; &nbsp; global $folderURL, $service;<br />&nbsp; &nbsp; if ($url === null)<br />&nbsp; &nbsp; &nbsp; &nbsp; $url = $folderURL;<br />&nbsp; &nbsp; $paging = array(&#039;url&#039; =&gt; $url, &#039;prefix&#039; =&gt; $prefix, &#039;postfix&#039; =&gt; &#039;&#039;);<br />&nbsp; &nbsp; if (empty($sql))<br />&nbsp; &nbsp; &nbsp; &nbsp; return array(array(), $paging);<br />&nbsp; &nbsp; if (preg_match(&#039;/\s(FROM.*)(ORDER BY.*)$/si&#039;, $sql, $matches))<br />&nbsp; &nbsp; &nbsp; &nbsp; $from = $matches[1];<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; return array(array(), $paging);<br />&nbsp; &nbsp; /* <strong>전체 카운트 구하는 쿼리는 별도</strong> */<br />&nbsp; &nbsp; $paging[&#039;total&#039;] = POD::queryCell(&quot;select count(*) from tc_entries where visibility = &#039;2&#039;&quot;);<br />&nbsp; &nbsp; if ($paging[&#039;total&#039;] === null)<br />&nbsp; &nbsp; &nbsp; &nbsp; return array(array(), $paging);<br />&nbsp; &nbsp; if (empty($count)) $count = 1;<br />&nbsp; &nbsp; $paging[&#039;pages&#039;] = intval(ceil($paging[&#039;total&#039;] / $count));<br />&nbsp; &nbsp; $paging[&#039;page&#039;] = is_numeric($page) ? $page : 1;<br />&nbsp; &nbsp; if ($paging[&#039;page&#039;] &gt; $paging[&#039;pages&#039;]) {<br />&nbsp; &nbsp; &nbsp; &nbsp; $paging[&#039;page&#039;] = $paging[&#039;pages&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; if ($paging[&#039;pages&#039;] &gt; 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $paging[&#039;prev&#039;] = $paging[&#039;pages&#039;] - 1;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //return array(array(), $paging);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; if ($paging[&#039;page&#039;] &gt; 1)<br />&nbsp; &nbsp; &nbsp; &nbsp; $paging[&#039;prev&#039;] = $paging[&#039;page&#039;] - 1;<br />&nbsp; &nbsp; if ($paging[&#039;page&#039;] &lt; $paging[&#039;pages&#039;])<br />&nbsp; &nbsp; &nbsp; &nbsp; $paging[&#039;next&#039;] = $paging[&#039;page&#039;] + 1;<br />&nbsp; &nbsp; $offset = ($paging[&#039;page&#039;] - 1) * $count;<br />&nbsp; &nbsp; if ($offset &lt; 0) $offset = 0;<br />&nbsp; &nbsp; if ($countItem !== null) $count = $countItem;</p><p>&nbsp; &nbsp; return array(POD::queryAll(&quot;$sql LIMIT $offset, $count&quot;), $paging);<br />}</p>]]></description>
			<author><![CDATA[null@example.com (박동섭)]]></author>
			<pubDate>Mon, 09 Jun 2008 11:33:55 +0000</pubDate>
			<guid>http://forum.tattersite.com/ko/viewtopic.php?pid=27787#p27787</guid>
		</item>
	</channel>
</rss>
