1111 * @version 2.2
1212 *
1313 * @method int count ()
14+ * @method dbObject ArrayBuilder()
15+ * @method dbObject JsonBuilder()
16+ * @method dbObject ObjectBuilder()
1417 * @method mixed byId (string $id, mixed $fields)
1518 * @method mixed get (mixed $limit, mixed $fields)
1619 * @method mixed getOne (mixed $fields)
@@ -181,21 +184,19 @@ public function __unset ($name) {
181184 *
182185 * @return dbObject
183186 */
184- public static function JsonBuilder () {
185- $ obj = new static ;
186- $ obj ->returnType = 'Json ' ;
187- return $ obj ;
187+ private function JsonBuilder () {
188+ $ this ->returnType = 'Json ' ;
189+ return $ return ;
188190 }
189191
190192 /**
191193 * Helper function to create dbObject with Array return type
192194 *
193195 * @return dbObject
194196 */
195- public static function ArrayBuilder () {
196- $ obj = new static ;
197- $ obj ->returnType = 'Array ' ;
198- return $ obj ;
197+ private function ArrayBuilder () {
198+ $ this ->returnType = 'Array ' ;
199+ return $ this ;
199200 }
200201
201202 /**
@@ -204,8 +205,9 @@ public static function ArrayBuilder () {
204205 *
205206 * @return dbObject
206207 */
207- public static function ObjectBuilder () {
208- return new static ;
208+ private function ObjectBuilder () {
209+ $ this ->returnType = 'Object ' ;
210+ return $ this ;
209211 }
210212
211213 /**
@@ -297,7 +299,7 @@ public function delete () {
297299 *
298300 * @return dbObject|array
299301 */
300- private function byId ($ id , $ fields = null ) {
302+ protected function byId ($ id , $ fields = null ) {
301303 $ this ->db ->where (MysqliDb::$ prefix . $ this ->dbTable . '. ' . $ this ->primaryKey , $ id );
302304 return $ this ->getOne ($ fields );
303305 }
@@ -310,7 +312,7 @@ private function byId ($id, $fields = null) {
310312 *
311313 * @return dbObject
312314 */
313- private function getOne ($ fields = null ) {
315+ protected function getOne ($ fields = null ) {
314316 $ this ->processHasOneWith ();
315317 $ results = $ this ->db ->ArrayBuilder ()->getOne ($ this ->dbTable , $ fields );
316318 if ($ this ->db ->count == 0 )
@@ -340,7 +342,7 @@ private function getOne ($fields = null) {
340342 *
341343 * @return array Array of dbObjects
342344 */
343- private function get ($ limit = null , $ fields = null ) {
345+ protected function get ($ limit = null , $ fields = null ) {
344346 $ objects = Array ();
345347 $ this ->processHasOneWith ();
346348 $ results = $ this ->db ->ArrayBuilder ()->get ($ this ->dbTable , $ limit , $ fields );
@@ -409,9 +411,11 @@ private function join ($objectName, $key = null, $joinType = 'LEFT') {
409411 *
410412 * @return int
411413 */
412- private function count () {
414+ protected function count () {
413415 $ res = $ this ->db ->ArrayBuilder ()->getValue ($ this ->dbTable , "count(*) " );
414- return $ res ['cnt ' ];
416+ if (!$ res )
417+ return 0 ;
418+ return $ res ;
415419 }
416420
417421 /**
@@ -608,6 +612,9 @@ private function validate ($data) {
608612 case "int " :
609613 $ regexp = "/^[0-9]*$/ " ;
610614 break ;
615+ case "double " :
616+ $ regexp = "/^[0-9\.]*$/ " ;
617+ break ;
611618 case "bool " :
612619 $ regexp = '/^[yes|no|0|1|true|false]$/i ' ;
613620 break ;
0 commit comments