小编mym*_*and的帖子

如何在MySQL中的现有列中添加非空约束

我有一个名为"Person"的表名,后面有列名

P_Id(int),
LastName(varchar),
FirstName (varchar).
Run Code Online (Sandbox Code Playgroud)

我忘了给NOT NULLConstraint P_Id.

现在我尝试使用以下查询将NOT NULLConstraint 添加到名为的现有列中P_Id,

1. ALTER TABLE  Person MODIFY  (P_Id NOT  NULL);
2. ALTER TABLE Person ADD CONSTRAINT NOT  NULL NOT NULL (P_Id);
Run Code Online (Sandbox Code Playgroud)

我收到语法错误....

mysql constraints

150
推荐指数
3
解决办法
19万
查看次数

如何在zend框架中打印精确的SQL查询?

我有以下一段代码,我从模型中取出,

    ...
                  $select = $this->_db->select()
                    ->from($this->_name)
                    ->where('shipping=?',$type)
                    ->where('customer_id=?',$userid);
                 echo  $select; exit; // which gives exact mysql query.
            .....
Run Code Online (Sandbox Code Playgroud)

当我在zend中使用更新查询时,

$up_value = array('billing'=> '0');
$this->update($up_value,'customer_id ='.$userid.' and address_id <> '.$data['address_Id']);      
Run Code Online (Sandbox Code Playgroud)

在这里,我想知道确切的mysql查询.有没有办法在zend中打印mysql查询?好心劝告

php mysql zend-framework zend-db

69
推荐指数
4
解决办法
12万
查看次数

如何使用jquery防止右键单击选项

是否可以阻止我们在网页中使用的图像的右键单击选项.

jquery

33
推荐指数
4
解决办法
9万
查看次数

表单提交时检查文件类型?

我的表格有以下字段,

<form onsubmit="return checkcreateform()" action="/gallery/create" method="post" enctype="multipart/form-data">
   <label>Type:*</label>
    <label for="type-1">
     <input type="radio" checked="checked" value="1" id="type-1" name="type">Image
    </label>
   <br>
   <label for="type-2">
   <input type="radio" value="2" id="type-2" name="type">Video
   </label>  
   <label class="itemdetailfloatL required" for="file">File:*</label>
   <input type="hidden" id="MAX_FILE_SIZE" value="8388608" name="MAX_FILE_SIZE">
   <input type="file" tabindex="5" class="text-size text" id="file" name="file">
 <input type="submit" value="Create" id="submit" name="submit">
</form>
Run Code Online (Sandbox Code Playgroud)

我想在表单提交之前验证.在这里我如何验证用户选择类型为图像并上传视频或选择类型为视频和上传图像?

我们可以通过javascript或jquery实现这一点.快速验证这个方法吗?

请帮助我.

html javascript jquery file-upload

18
推荐指数
3
解决办法
7万
查看次数

在localhost中发送邮件需要很长时间

我正在使用Ubuntu.我使用以下命令在我的本地主机上安装了sendmail

sudo apt-get install sendmail
Run Code Online (Sandbox Code Playgroud)

现在我想使用以下php代码检查邮件是否来自我的localhost.

<?php
$to = "test@test.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?> 
Run Code Online (Sandbox Code Playgroud)

当我执行代码时,它需要很长时间,最后将邮件作为邮件发送回显.有没有可能解决这个问题?

php ubuntu sendmail

17
推荐指数
2
解决办法
2万
查看次数

如何修复Zend中的"无法发送标头;已发送的标头"?

可能重复:
PHP已发送的标头

我是zend的新手.我尝试使用zend创建包含两个字段的简单表单.当我点击提交按钮时出现以下错误,

Fatal error: Uncaught exception 'Zend_Controller_Response_Exception' with message 'Cannot send headers; headers already sent in D:\xampp\htdocs\study\quickstart\application\controllers\EmployeeController.php, line 35' in D:\xampp\php\PEAR\Zend\Controller\Response\Abstract.php:282 Stack trace: #0 D:\xampp\php\PEAR\Zend\Controller\Response\Abstract.php(300): Zend_Controller_Response_Abstract->canSendHeaders(true) #1 D:\xampp\php\PEAR\Zend\Controller\Response\Abstract.php(727): Zend_Controller_Response_Abstract->sendHeaders() #2 D:\xampp\php\PEAR\Zend\Controller\Front.php(984): Zend_Controller_Response_Abstract->sendResponse() #3 D:\xampp\php\PEAR\Zend\Application\Bootstrap\Bootstrap.php(77): Zend_Controller_Front->dispatch() #4 D:\xampp\php\PEAR\Zend\Application.php(358): Zend_Application_Bootstrap_Bootstrap->run() #5 D:\xampp\htdocs\study\quickstart\public\index.php(25): Zend_Application->run() #6 {main} thrown in D:\xampp\php\PEAR\Zend\Controller\Response\Abstract.php  on line 282
Run Code Online (Sandbox Code Playgroud)

我检查了以下链接, zend header已经发送问题了

我删除了空格并在所有文件中给出了密切标记,但我仍然得到同样的错误.

如何解决这个错误?

以下显示了EmployeeController.php:

<?php 
class EmployeeController extends Zend_Controller_Action
{
    public function init()
    {

    }
    public function indexAction()
    {

      $form = new Default_Form_Empdetails();
       $this->view->form = $form; …
Run Code Online (Sandbox Code Playgroud)

php zend-framework

12
推荐指数
1
解决办法
3万
查看次数

如何在页面刷新时阻止调用onbeforeunload

我希望在confirmExit()刷新页面时阻止调用该函数.有可能吗?

<script language="JavaScript">
window.onbeforeunload = confirmExit;
function confirmExit()
{
   $.post("test.php");
}
</script>
Run Code Online (Sandbox Code Playgroud)

jquery

10
推荐指数
2
解决办法
2万
查看次数

如何使用strlen()在php中查找字符串长度?

如何在php中找到字符串的长度而不使用strlen()

php string

10
推荐指数
3
解决办法
3万
查看次数

触发器不是在Mysql中创建的

我已经在cpanel和DB中创建了一个用户并且给ALLPRIVILEGES了该用户并尝试导入sql dump,结果是" TRIGGER command denied to user 'test'@'localhost' for table 'tablename'".但是它在我的本地工作.我在这个过程中做错了什么?亲切地帮助我.

mysql privileges

5
推荐指数
1
解决办法
1万
查看次数

使用Promises在for循环中调用API的最佳方法

我有5亿个对象,其中每个都有n个联系人,如下所示

var groupsArray = [
                    {'G1': ['C1','C2','C3'....]},
                    {'G2': ['D1','D2','D3'....]}
                     ...
                    {'G2000': ['D2001','D2002','D2003'....]}
                     ...
                ]
Run Code Online (Sandbox Code Playgroud)

我在nodejs中有两种实现方式,它基于常规promise,另一种方法使用bluebird,如下所示

定期承诺

...
var groupsArray = [
                    {'G1': ['C1','C2','C3']},
                    {'G2': ['D1','D2','D3']}
                ]

function ajax(url) {
  return new Promise(function(resolve, reject) {
        request.get(url,{json: true}, function(error, data) {
            if (error) {
                reject(error);
            } else {
                resolve(data);  
            }
        });
    });
}
_.each(groupsArray,function(groupData){
    _.each(groupData,function(contactlists,groupIndex){
        // console.log(groupIndex)
        _.each(contactlists,function(contactData){
            ajax('http://localhost:3001/api/getcontactdata/'+groupIndex+'/'+contactData).then(function(result) {
                console.log(result.body);
              // Code depending on result
            }).catch(function() {
              // An error occurred
            });
        })
    })
})
...
Run Code Online (Sandbox Code Playgroud)

使用bluebird方式我使用并发来检查如何控制promises队列

...
_.each(groupsArray,function(groupData){
    _.each(groupData,function(contactlists,groupIndex){
        var …
Run Code Online (Sandbox Code Playgroud)

javascript node.js promise bluebird

5
推荐指数
1
解决办法
1792
查看次数