From: edward Date: Mon, 19 Mar 2018 03:26:40 +0000 (+0800) Subject: mysql/core_images_count.sql X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=commitdiff_plain;h=afaa2b4424ce46221070730160f7355a0d8e13d7 mysql/core_images_count.sql --- diff --git a/mysql/core_images_count.sql b/mysql/core_images_count.sql index ee33a484..83b1cb82 100644 --- a/mysql/core_images_count.sql +++ b/mysql/core_images_count.sql @@ -1,10 +1,20 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -/** - * Author: edward - * Created: Mar 19, 2018 - */ +DROP FUNCTION IF EXISTS core_images_count; + +DELIMITER $$ +CREATE FUNCTION core_images_count( + in_ontable VARCHAR(128), + in_onid INT(11) +) +RETURNS INT(4) NOT DETERMINISTIC READS SQL DATA + BEGIN + + DECLARE v_ret INT(4); + + SELECT COUNT(id) INTO v_ret FROM Images WHERE ontable = in_ontable AND onid = in_onid; + + RETURN v_ret; + + END $$ + +DELIMITER ; \ No newline at end of file