mysql,symfony1,doctrineRelated issues-Collection of common programming errors
Dino
mysql sql select
suppose the user inputmysite.com/profile?identity=1 mysite.com/profile?identity=dinodsja mysite.com/profile?identity=1agetting the value$identity = $_GET[‘identity’]; // identity can be user_id or user_nameand i have a simple select query:SELECT * FROM lb_users WHERE (user_id = ‘dinodsja’ OR user_name = ‘dinodsja’) AND user_status = 1and it works fine. but the problem is:SELECT * FROM lb_users WHERE (user_id = ‘1a’ OR user_name = ‘1a’) AND user_status = 1when I execute this query it also returns
John Gold
mysql null
What “Allow Null” means and does? Thanks!
Noah
mysql ruby-on-rails database sqlite
After much googling I have been wondering what the benefits/differences are between mysql and sqlite3. I am primarily hoping for a speed bump when moving my development database to my production database, although I imagine this will primarily happen in my code. Does any know what the major differences are in performance? ARE there? Or would you be able to point me in the direction of some literature comparing the two?
musical_coder
php mysql database parsing login
i got a parsing error for a database that i want to either retrieve and/or delete data/input – this is the error message that i get – *Parse error: syntax error, unexpected ‘public’ (T_PUBLIC) in C:\xampp\htdocs\ooplr\classes\DB.php on line 66*here are the codes for the file that is giving me the error:<?phpclass DB{ private static $_instance = null; private $_pdo, $_query, $_error = false, $_results, $_count =0;private static function __construct(){try {$this->_pdo = new PDO(‘mysql:host=’
Clive
php mysql
If $userid equals $row[‘RequestRecipientID’] then the script will output all $row[‘StatusType’] which equals “Accepted”. What I’m needing for this script to do is only output the $row[‘StatusType’] which equals to the $userid. Any ideas?<?php include(“enc.php”); mysqlcon(); $userid = $_SESSION[‘userid’]; $results = mysql_query(“SELECT requests.RequestRecipientID, requests.StatusType, requests.AddedMessage, requests.FriendType, requests.RequestSentByID, requests.id, users.username, users.first
user2241559
mysql shell scripting
I’m trying to iterate through a delimited text file and insert those into a mysql DB table using a shell script. #!/bin/bash while IFS=’|’ read val1 val2 val3 #cat testfile.txt | while read line do#val1=`echo $line | cut -d’|’ -f1`#val2=`echo $line | cut -d’|’ -f2`#val3=`echo $line | cut -d’|’ -f3`echo $val1 $val2 $val3/usr/local/mysql/bin/mysql –host=127.0.0.1 –user=root –password= test << EOFinsert into addressTable(street,city,zip)values(‘$val1′,’$val2′,’$val3’)EOF done < testfile
Riong Riong
php mysql forms email
Check my code, everytime I press submit it tells me…Parse error: syntax error, unexpected T_STRING in /1111111111/2222222222222222222/33333333/444444444444444444444444444 on line 21Its frustrating. I thought I had everthing right. Here’s my php file:<?php$email = $_POST[’email’];if ($username == null ||$email == null ||$password == null ) { die(“You must fill out everything on the form!”); } else { //continue…} $conn = mysql_connect(“$############”, “$############”,”$#############
Ivelyne Jacout
php mysql wordpress
Odd problem, let me try and explain it clearly. I wrote a WordPress plugin, and it’s been installed on dozens of servers without issue. A client tried to install it today, and they received the following error Parse error: syntax error, unexpected ‘}’ in /sitepathhere/wp-content/plugins/myplugin/insert.php on line 302 The function was outputting text via an echo rather than returning text. Fine, I changed it to return the text and all worked ok for that part. Then the admin panel and front end
lyhong
mysql
I have two tables with related key. I want to choose the best way to delete row from tbl_one and tbl_two rows that have related key. I tried using DELETE JOIN to do this correctly, but I found another way that is very simple that I use two statements of delete. Could you tell me which is better? First method:DELETE tbl_one, tbl_two FROM tbl_one JOIN tbl_two ON tbl_one.id = tbl_two.tbl_one_id WHERE tbl_one.id = 1Second method:DELETE FROM tbl_one WHERE id =1; DELETE FROM tbl_two WHERE tbl_one_id
G-Nugget
mysql innodb percona
I just installed Percona 5.6 on my new CentOS 6.4 server. It’s a fast machine 32 core xenon, 72GB ram, 8x SAS RAID 10 setup. So far so good My old server is a bit less powerful, and was running MySQL 5.1 still. So this was quite an upgrade. But I’m having some issues with InnoDB, it is not using the indexes correctly on some tables it seems. Where on my old machine the same queries were running fine.Both servers have the same database. I did a mysqldump on the old machine and imported it onto th
Hans Mayer
php mysql symfony1 propel
I’ve got a problem:I have a schema.yml which contains a field with the type “time”:time_space: { type: time, required: true }For my initial data, I have a fixture file which contains a value for the field “time_space”:time_space: 24:00:00 # doesn’t workWhen I look into my propel.ini (which isn’t modified of me so far), I see the following setting:propel.defaultTimeFormat = H:i:sMy error message is following when I execute ‘symfony propel:data-load’ in my CLI:Error parsing date/time valu
j0k
php symfony1
I have a symfony 1.4 application with some classes for connecting to a SOAP web service stored in apps/appname/lib. When I try to access the sfConfig class to get some variables I have set in app.yml, an error is thrown since the application doesn’t recognize sfConfig::get(‘app_myvar’) as a method being called on a class.How do I make the sfConfig class available to the classes in my apps/appname/lib directory?This is the error I’m gettingParse error: syntax error, unexpected ‘(‘, expecting ‘,’
TuK
php validation symfony1
I have a form for changing passwords, it checks the password field for min_length and required. Then it compares the password field with the confirm field.If I post to this form with less than the minimum required characters (and the password and confirm box match), it throws errors for min length (which is expected) and for password mismatch (unexpected). Can anyone tell why?<?phpclass ChangeMyPasswordForm extends sfForm {const PASSWORD_MIN_LENGTH_MSG = “<li>We could not update your pa
Clement Herreman
php symfony1 doctrine dql doctrine-collection
I’ve a method that returns a Doctrine_Collection, with a whereIn() clause :public function getByValues($values) {if (!is_array($values))throw new sfException(‘Wrong parameter type. Excepted array.’);return Doctrine_Query::create()->from(‘Anomaly a’)->whereIn(‘a.value’, $values); }However, when $values is an empty array, this method return all the rows that are in the AnomalyTable. This isn’t an unexpected behavior, as documented in Doctrine documentation, and written here : Doctrine where
Manu
symfony1 http-status-code-404 http-status-code-500
I’ve created custom 404 error pages for my symfony application, but they don’t seem to work. In dev I see :This request has been forwarded to a 404 error page by the action “blabla”.But in prod, the page is just blank; I get a 500 error.In the logs, the error is :PHP Parse error: syntax error, unexpected T_PUBLIC in /var/www/myproject/apps/myapp/modules/default/actions/actions.class.php on line 7default/actions/actions.class.php is the following :<?php /*** Error page for page not found (404
quardas
forms symfony1
I’ve been creating with a ajax and doctrine chain-dropdown to select a category. I put them in component. It works like this:http://www.plus2net.com/php_tutorial/ajax_drop_down_list.phpIm trying to replace default category dropdown build on schema and related with current table. When in /lib/form/doctrine/TabbleForm.class.phpI remove a field with code:unset($this[‘category’]);And in the tamplate which has a form body I paste a component code (with this dynamic ajax-based dropdown):include_compon
Andreu Heineken
javascript jquery symfony1 jstree
i did a descendant tree for an entity in my app, using the libray jstree. I do what is usual to use it:show an <ul> & <li> structure as usual then i apply the .jstree(…) function to the parent <div> of the structure.I’m sorry but i can’t provide you my source code because is dynamically generated from diferent parts of the app, but i can show a result example of the <ul>&<li> structure:<div id=”unidadtree”> <ul><li id=182 ><a href=”-ce
AnchovyLegend
symfony2 frameworks symfony1 twig
For pages with lots of text and html tags, I quickly get a parsing error from Twig due to unexpected special characters. Has anybody else ran into this problem?Unexpected character “!” in … at line 76I am trying to fix this problem by pasting the static information in a new page and then including it using include. My question is, where should I place a static HTML file so it can be included in a Twig file using {% include ‘content.html’ %}? Currently the included file is in the FooBundle/Reso
prongs
php symfony1 symfony-1.4 admin-generator
my security.yml: all:is_secure: truenew:credentials: [add_ticker_source] edit:credentials: [edit_ticker_source] delete: credentials: [delete_ticker_source] batchDelete: //I don’t know whether it is correct. Should it be batch_delete?credentials: [delete_ticker_source] batch_delete: credentials: [delete_ticker_source]index: is_secure: falsein my generator.yml, I added list:batch_actions:_delete: {credentials: delete_ticker_source}then I commented last two lines and opened list view in my browser.
Andreu Heineken
php sql join symfony1 symfony-1.4
i’m trying to do a complex query with Criteria in a Symfony project using Propel ORM.the query i want to make is, in human words:Select from the ‘interface’ table the registers that: – 1 are associated with a process (with a link table) – 2 have a name similat to $name – 3 its destiny application’s name is $apd (application accecible by foreign key) – 4 its originapplication’s name is $apo (application accecible by foreign key)here the code i made, and not working:$c = new Criteria();$c->add
user1987373
sql symfony2 doctrine doctrine2 dql
I have a Repository Class with a method to call a custom Query. When I try to call findAllWithRating() from inside a controller I got the following exception:[2/2] QueryException: [Syntax Error] line 0, col 156: Error: Unexpected ‘NULL’If I try to call the query within phpmyadmin the query works great! Any Idea?<?php namespace Anchorbrands\Bundle\MessageBundle\Entity;use Doctrine\ORM\EntityRepository;class MessageRepository extends EntityRepository {public function findAllWithRating() {return
k314
zend-framework doctrine
I got problem with Doctrine. I add this lines in my application.ini:includePaths.model = APPLICATION_PATH “/models”autoloaderNamespaces[] = “Doctrine”doctrine.dns = “mysql://root@localhost/translators” dectrine.data_fixtures_path = APPLICATION_PATH “/doctrine/data/fixtures” doctrine.models_path = APPLICATION_PATH “/models” doctrine.migrations_path = APPLICATION_PATH “/doctrine/migrations” doctrine.sql_path = APPLICATION_PATH “/doctrine/data/sql” doctrine.yaml_schema_path = “APPLICATION_PATH “/do
borrible
php doctrine
I am seeing an unexpected caching effect in Doctrine (1.2.4).I have a couple of related tables defined by the following YAML (several additional fields not used in the example removed). Just a simple 1-Many relationship from students to schools.School:tableName: tblschoolcolumns:sch_id:name: sch_id as idprimary: trueautoincrement: truetype: integer(4)sch_name:name: sch_name as nametype: string(50) Student:tableName: tblstudentcolumns:stu_id:name: stu_id as idprimary: trueautoincrement: truetype
YorkshireDeveloper
php doctrine2 doctrine doctrine-query
I am trying to do a simple query in doctrine but struggling. $query->select(array(‘app_title’ => ‘u.title’,’user_name’ => ‘u.user_name’,’first_used’ => ‘MIN(u.creation_time)’,’last_used’ => ‘MAX(u.stop_time)’,’total_usage’ => ‘SUM(u.stream_seconds)’, )) ->from(self::USAGE_TABLE, ‘u’) ->orderBy(‘total_usage’, ‘DESC’);Obviously I get an error about the column name not being known because Doctrine is using it’s own aliases (sclr4). However, if I try and order by the actual v
XMen
php doctrine dbal
I want to use Doctrine DBAL , I downloaded the DBAL folder from a site. and put the folder on my server . and then write this code in my file .use Doctrine\Common\ClassLoader;require ‘Doctrine/Common/ClassLoader.php’;$classLoader = new ClassLoader(‘Doctrine’, ‘Doctrine’); $classLoader->register(); $config = new \Doctrine\DBAL\Configuration(); //.. $connectionParams = array(‘dbname’ => ‘mydb’,’user’ => ‘user ‘,’password’ => ‘password’,’host’ => ‘host’,’driver’ => ‘pdo_mysql’, );
j0k
symfony2 doctrine doctrine2 dql
I am developing an application using Symfony2 and DQL for building some queries in the repositories. I have the next code in the controller:$emGalPak = $this->getDoctrine()->getEntityManager();$OsatugabeKop = $emGalPak->getRepository(‘AnotatzaileaAnotatzaileaBundle:GalderaPaketea’)->getOsatugabeKop(); and this is the query I built in the repository corresponding to the entity mentioned above:<?phpnamespace Anotatzailea\AnotatzaileaBundle\Repository;use Doctrine\ORM\EntityRepositor
Clement Herreman
php symfony1 doctrine dql doctrine-collection
I’ve a method that returns a Doctrine_Collection, with a whereIn() clause :public function getByValues($values) {if (!is_array($values))throw new sfException(‘Wrong parameter type. Excepted array.’);return Doctrine_Query::create()->from(‘Anomaly a’)->whereIn(‘a.value’, $values); }However, when $values is an empty array, this method return all the rows that are in the AnomalyTable. This isn’t an unexpected behavior, as documented in Doctrine documentation, and written here : Doctrine where
David Weinraub
php orm doctrine yaml case
Just getting started with Doctrine ORM for PHP (v1.1.5) and ran into something unexpected.I am generating models from the db (MySQL 4) using:Doctrine::generateModelsFromDb($pathToModels);Then generating YAML from the models using:Doctrine::generateYamlFromModels($pathToSchema . ‘/schema.yml’, $pathToModels);In the generated models, the column names (as defined in hasColumn()) use the same case for the fields as in the db. All good.But in the generated YAML, the column names are all lower-case, i
Manolo Salsas
php symfony2 doctrine
According to Symfony2 documentation, I can access to instances in database with the next code:public function showAction($id) { $producto = $this->getDoctrine() ->getRepository(‘AcmeGuardaBundle:Producto’) ->find($id); $nombreCategoria = $producto->getCategoria()->getNombre(); // … }However, I try to do:$imagen = $this->getDoctrine()->getRepository(‘MSDHomeBundle:Imagen’)->find($_SESSION[‘id’]);and I get the next error in the browser:Parse error: syntax error, unexpecte
user944448
jquery doctrine
Need help with this one. I’m kind of confuse. For me everything seems fine but I’m still getting errorParse error: syntax error, unexpected ‘(‘, expecting T_VARIABLE or ‘$’Here’s my codeecho “$(‘.gro-ls’).click(function(){$(this).css({background:’red’})});”;Can someone please tell me what’s wrong with this one?ThanksEdited: All the answers worked. Thanks guys
Web site is in building