Jump to content


Photo

Create Contact, apostrophe error in business name field

Special Characters Create Contact CDbException

  • Please log in to reply
2 replies to this topic

#1 declan

declan

    Member

  • Members
  • PipPip
  • 15 posts

Posted 01 May 2012 - 01:11 PM

x2 1.2.2
host OS Fedora 14

When I enter the name of a company in the Create Contact Form View, I get the following error if it contains an apostrophe. In my case Sharkey's Cuts for Kids.

Thank you in advance,

Declan

CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's')
OR (secondType='Contacts' AND seco' at line 2. The SQL statement executed was: SELECT * FROM x2_relationships WHERE
(firstType='Contacts' AND firstId='16' AND secondType='Accounts' AND secondId='Sharkey's')
OR (secondType='Contacts' AND secondId='16' AND firstType='Accounts' AND firstId='Sharkey's')

/var/www/html/framework/db/CDbCommand.php(528)

516 return $result;
517 }
518 catch(Exception $e)
519 {
520 if($this->_connection->enableProfiling)
521 Yii::endProfile('system.db.CDbCommand.query('.$this->getText().$par.')','system.db.CDbCommand.query');
522 $errorInfo = $e instanceof PDOException ? $e->errorInfo : null;
523 $message = $e->getMessage();
524 Yii::log(Yii::t('yii','CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.',
525 array('{method}'=>$method, '{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
526 if(YII_DEBUG)
527 $message .= '. The SQL statement executed was: '.$this->getText().$par;
528 throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
529 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
530 }
531 }
532
533 /**
534 * Builds a SQL SELECT statement from the given query specification.
535 * @param array $query the query specification in name-value pairs. The following
536 * query options are supported: {@link select}, {@link distinct}, {@link from},
537 * {@link where}, {@link join}, {@link group}, {@link having}, {@link order},
538 * {@link limit}, {@link offset} and {@link union}.
539 * @return string the SQL statement
540 * @since 1.1.6


Stack Trace
#0

+ /var/www/html/framework/db/CDbCommand.php(408): CDbCommand->queryInternal("fetch", array(2), array()) #1

+ /var/www/html/framework/db/ar/CActiveRecord.php(1494): CDbCommand->queryRow() #2

– /var/www/html/protected/controllers/x2base.php(368): CActiveRecord->findBySql("SELECT * FROM x2_relationships WHERE ...")

363 foreach($fields as $field){
364 $fieldName=$field->fieldName;
365 if(isset($model->$fieldName)){
366 if(is_null(Relationships::model()->findBySql("SELECT * FROM x2_relationships WHERE
367 (firstType='$name' AND firstId='$model->id' AND secondType='".ucfirst($field->linkType)."' AND secondId='".$model->$fieldName."')
368 OR (secondType='$name' AND secondId='$model->id' AND firstType='".ucfirst($field->linkType)."' AND firstId='".$model->$fieldName."')"))){
369 $rel=new Relationships;
370 $rel->firstType=$name;
371 $rel->secondType=ucfirst($field->linkType);
372 $rel->firstId=$model->id;
373 $rel->secondId=$model->$fieldName;
#3

– /var/www/html/protected/modules/contacts/controllers/DefaultController.php(255): x2base->create(Contacts, array("company" => "Sharkey's", "id" => null, "firstName" => null, "lastName" => null, ...), "0")

250 // Creates contact record
251 public function create($model, $oldAttributes, $api){
252 $model->createDate=time();
253 $model->lastUpdated=time();
254 if($api==0)
255 parent::create($model,$oldAttributes,$api);
256 else
257 return parent::create($model,$oldAttributes,$api);
258 }
259
260 // Controller/action wrapper for create()
#4

– /var/www/html/protected/modules/contacts/controllers/DefaultController.php(318): DefaultController->create(Contacts, array("company" => "Sharkey's", "id" => null, "firstName" => null, "lastName" => null, ...), "0")

313
314 }
315 }
316 if(!isset($model->visibility))
317 $model->visibility=1;
318 $this->create($model,$temp,'0');
319
320 }
321 $this->render('create',array(
322 'model'=>$model,
323 'users'=>$users,
#5

+ /var/www/html/framework/web/actions/CInlineAction.php(50): DefaultController->actionCreate() #6

+ /var/www/html/framework/web/CController.php(309): CInlineAction->runWithParams(array()) #7

+ /var/www/html/framework/web/filters/CFilterChain.php(134): CController->runAction(CInlineAction) #8

+ /var/www/html/protected/controllers/x2base.php(988): CFilterChain->run() #9

+ /var/www/html/framework/web/filters/CInlineFilter.php(59): x2base->filterSetPortlets(CFilterChain) #10

+ /var/www/html/framework/web/filters/CFilterChain.php(131): CInlineFilter->filter(CFilterChain) #11

+ /var/www/html/framework/web/filters/CFilter.php(41): CFilterChain->run() #12

+ /var/www/html/framework/web/CController.php(1146): CFilter->filter(CFilterChain) #13

+ /var/www/html/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(CFilterChain) #14

+ /var/www/html/framework/web/filters/CFilterChain.php(131): CInlineFilter->filter(CFilterChain) #15

+ /var/www/html/framework/web/CController.php(292): CFilterChain->run() #16

+ /var/www/html/framework/web/CController.php(266): CController->runActionWithFilters(CInlineAction, array("accessControl", "setPortlets")) #17

+ /var/www/html/framework/web/CWebApplication.php(276): CController->run("create") #18

+ /var/www/html/framework/web/CWebApplication.php(135): CWebApplication->runController("contacts/default/create") #19

+ /var/www/html/framework/base/CApplication.php(162): CWebApplication->processRequest() #20

+ /var/www/html/index.php(63): CApplication->run()
2012-05-01 16:59:23 Apache/2.2.17 (Fedora) Yii Framework/1.1.9

#2 X2Jake

X2Jake

    X2 Engineer

  • Administrators
  • 1275 posts
  • LocationSanta Cruz

Posted 01 May 2012 - 01:16 PM

This is a known issue that has been fixed in our upcoming release of X2CRM.
Jake Houser

Software Engineer at X2Engine

jake@x2engine.com

#3 declan

declan

    Member

  • Members
  • PipPip
  • 15 posts

Posted 01 May 2012 - 02:00 PM

My apologies for reposting a known issue...I look forward to the upcoming release.

Warm Regards,

Declan





Also tagged with one or more of these keywords: Special Characters, Create Contact, CDbException

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users