如何使用zend framework 1.12执行sql文件file.sql?

时间:2016-03-17 12:31:54

标签: php mysql zend-framework

Php脚本:

System.Windows.Data Warning: 90 : BindingExpression (hash=35938393): Update - got raw value '1'
System.Windows.Data Warning: 94 : BindingExpression (hash=35938393): Update - using final value '1'
System.Windows.Data Warning: 102 : BindingExpression (hash=35938393): SetValue at level 0 to IntContainer (hash=56037929) using ReflectPropertyDescriptor(Value): '1'
System.Windows.Data Warning: 95 : BindingExpression (hash=35938393): Got ValueChanged event from IntContainer (hash=56037929)
System.Windows.Data Warning: 101 : BindingExpression (hash=35938393): GetValue at level 0 from IntContainer (hash=56037929) using ReflectPropertyDescriptor(Value): '1'
System.Windows.Data Warning: 80 : BindingExpression (hash=35938393): TransferValue - got raw value '1'
System.Windows.Data Warning: 89 : BindingExpression (hash=35938393): TransferValue - using final value '1'

如果sql文件包含简单的SQL查询,它对我有用。

我的sql文件包含一个过程声明:

   $db = Zend_Db_Table::getDefaultAdapter();
   $file_content = file_get_contents('file.sql', FILE_USE_INCLUDE_PATH);
   if($file_content!=''){
       $db->query($sql);
   }

2 个答案:

答案 0 :(得分:1)

如果file.sql的内容用作sql查询字符串,它应该如下所示(没有“分隔符”):

CREATE PROCEDURE PROC()
BEGIN
    ALTER ...... ;
    DELETE ..... ;
END

另外,请事先检查数据库中是否存在某个程序:

SELECT EXISTS (SELECT 1 FROM mysql.proc p WHERE db = 'db_name' 
AND name = 'PROC');

答案 1 :(得分:0)