Jump to content

BagoZonde

Members
  • Posts

    69
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.vintagecarousel.pl

Profile Information

  • Gender
    Male
  • Interests
    PHP, 6502 ASM, C64, painting, design, electronics, music!

BagoZonde's Achievements

Newbie

Newbie (1/5)

2

Reputation

  1. Ok, one person asked me about this problem privately an hour ago, so after a few years, well, just two years, I can answer to my question . Hope it helps other. This is very easy task, as .htaccess must be available in both directories. And the only difference between them is RewriteBase parameter: For main directory it will be: RewriteBase / And for test_directory it will be just: RewriteBase /test_directory So it's easy to keep whole project in separate directory nested in other one. I must say that it's funny how everything has changed in my development workflow since this post. For now I'm using VM with Vagrant and Ansible provisioning, Jenkins and so on. For this particular example I would rather expose my VM for somebody, or just create some staging server, etc. however sometimes it's quicker just to put some files somewhere so here is an answer. I hope everything's clear .
  2. Ok, it was really easy thanks to validation_groups so all fields are available in one entity but splitted into groups. About serializing these fields to one "settings" field, I've used callbacks in that same entity like postLoad, prePersist and preUpdate. Case closed.
  3. Hello! Is anybody know how to build Symfony 2 form (using Doctrine 2 and annotations) described as: 1. I have KingEntity which contains "type", "settings" and "something_else" fields. "Settings" field will contain serialized data as it can differ depending on "type" selected. 2. When type==1 I want get child-form (or something like that) QueenOne. And when type==2, I want get child-form QueenTwo, and so on. Each Queen* form contains different fields that's why I want to serialize it and put in "settings" field. I don't want to create new tables in database and create relations between them at all. 3. So, if type==1 is selected, I want validate this form using QueenOne form. If validation success, I want to serialize that data from QueenOne and put into "settings" field of KingEntity, so KingEntity is keeped in database and it contains only "type", "settings" and "something_else" fields. 4. I'm not interested with viewing this form, I need only backend part of logic for this kind of form. I hope I've explained it clearly. Any help will be appreciated.
  4. Well, finally I achieved my target few days ago. So, I've installed Virtual Box with Ubuntu, and I've used shared folder (/media/sf_htdocs) to share httdocs/ folder between Win8 and Ubuntu (@Virtual Box). Then I've mounted that folder with /home so I can access /home/[user]/public_html directly: sudo mount --bind /media/sf_htdocs/SomeProject/home /home so for now everything works like a charm. I can access site from the root. It was just Windows issue as that type of sites works well on *nix systems.
  5. I was talking with some advanced coder and he told me that path solution is possible to work properly only on some *nix (I'm working on Win8).
  6. Thank you for reply, kicken. I'm wonder how it works on live server (I'm not an author of this code). I can't change every place with __ROOTPATH__ (there are few of them), so how it works exactly? In other words, how to set my local server that same way as it was set on live serv? How to do it without touching anything in code? I don't get it.
  7. Hello everyone, I'm making some improvements to site I haven't created so please tell me how it exactly works as I have problems to configure it properly. I've downloaded all files and run localhost using XAMPP. Site should run when accessing /home/some_domain/public_html/index.php so I've created : <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/SomeProject/home/some_domain/public_html" ServerName some_project <Directory "C:/xampp/htdocs/SomeProject/home/some_domain/public_html"> AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> That means, when I'm accessing http://some_project it runs index.php And that's ok. In index.php there's some include: include_once("includes/startup.php"); So it includes relatively there: /home/some_domain/public_html/includes/startup.php And that's fine. However... In startup.php there's something like this: define("_ROOTPATH_","/home/some_domain/public_html/"); and next line: include_once(_ROOTPATH_ ."includes/config.php"); And that's my problem as index.php was executed from C:/xampp/htdocs/SomeProject/home/some_domain/public_html/ so that include_once will behave this way: C:/xampp/htdocs/SomeProject/home/some_domain/public_html/home/some_domain/public_html/includes/config.php Of course such file is not available as it should direct to: C:/xampp/htdocs/SomeProject/home/some_domain/public_html/includes/config.php I'm not sure how it works on server and what I should do with my localhost to achieve that same environment. $_SERVER['DOCUMENT_ROOT'] for real site is: /home/some_domain/public_html Please help me to understand what I'm doing wrong.
  8. Ok, finally it's done. I was using some old extension for PDO written one year ago where some fetches were treated in other way. That means I was looking in wrong place but I've tested it with mysqli and that kind of SELECT was executed well. So, thanks to fetchAll(PDO::FETCH_GROUP) I'm getting two arrays (first for table1 and second one for table2) with data inside them. So this is the winner query for 100% clarity once again: (SELECT "table1" AS type, id, title, url FROM table1 ORDER BY id DESC LIMIT 0, 10) UNION (SELECT "table2" AS type, id, title, url FROM table2 ORDER BY id DESC LIMIT 0, 10) My dream-loop is happy now :]. Thanks guys for help, especially for CrossMotion for hint with "fake" column name. That's a key! I'm not sure if this method is possible with mysqli as I want to get results in two arrays for each table, however PDO makes it possible easy way :]. I hope it will help somebody else in future. Thanks!
  9. Thanks a lot, CrossMotion. I remember that I saw that attempt with additional field. So thanks to your hint, I do it that way as I have problems with LIMIT, but first that's a query that works well: SELECT "table1" AS type, id, title, url FROM table1 UNION SELECT "table2" AS type, id, title, url FROM table2 ORDER BY id DESC One thing about this query I'm not sure: I'm using PDO in PDO::FETCH_GROUP mode so first column determine grouping into array for "table1" and "table2" where results are nested. So no GROUP BY type was used there (and I'm not sure in regular mysql_ or mysqli_ GROUP BY would be needed). When I've added "GROUP BY type" of that query, it returns all results of "table1" and only one result of "table2"?! That's wrong because there should be more for sure! I was also trying with UNION ALL without luck. When trying to execute your query, I got error from PDO: SQLSTATE[HY000]: General error: 1221 Incorrect usage of UNION and ORDER BY It seems that selects must be in parentheses when ORDER BY used (that same for LIMIT), however when parantheses were added, it returns no results for this query: (SELECT "table1" AS type, id, title, url FROM table1 ORDER BY id DESC LIMIT 0, 10) UNION (SELECT "table2" AS type, id, title, url FROM table2 ORDER BY id DESC LIMIT 0, 10) My dream-loop is still sad ;].
  10. While iteratation of results I want to know from which table that records comes so I need some identification like GROUP. Two separate queries is what I got for now but I'm not spellbound and just looking for one query (it's for practice and exploring new things in MySQL you know :]). This is my dream-loop in general: foreach($result as $group){ //Each column starts there, no matter if no records at all in first or second table print '<div class="column">'; foreach($group as $tableName=>$record){ //Let's rock with results for single table print '<div class="box box_' . $tableName . '">' . $record['title'] . '</div>'; } print '</div>'; //End of column div }
  11. Hello, I have googled everywhere so I suppose it's impossible but it's better to ask you, MySQL/PHP Freak gurus :]. I have two tables: table1 and table2. They represents content which are very different in structure, but both contains in common these fields: id, title, url and publish. I want to display list of contents: last 10 records from table1 to the left side and last 10 records from table2 to the right side. It's very simple with two queries. Just some: SELECT id, title, url FROM table1 WHERE publish=1 ORDER BY id DESC LIMIT 0, 10 However I'm concerned if it's possible to achieve to have two selects in single query (some UNION maybe) and GROUP by SELECT (something like GROUP BY table comes to my mind). Maybe there's some trick with LEFT JOIN, etc. I'm just curious.
  12. I think it could be something with Facebook's cache (I was reading about it few minutes ago) as I tried to share old link (never exposed to Facebook) and it works well! However Facebook Debugger should work that same way but he doesn't and returns everything (as well as proper image) in right way. I'm confused.
  13. Hello! I hope this is the right place to ask. I'm using Facebook PHP SDK (v.3.2.2) to share link on my Facebook's wall. Everything works fine, I can submit link and message. However there's a problem with image. Sometimes Facebook will find image I've expected but often he's selecting CAPTCHA image (which is located in HTML code at the bottom of page). So, how can I pick up right image for sharing on Facebook wall? When I'm sharing exactly that same links by hand on Facebook's wall - everything works fine, but with SDK it sucks very often. I was trying two things without luck: 1. Post picture's filepath (see: PHP example below). 2. By inserting: <meta property="og:image" content="http://www.absolutepath.to/image.jpg" /> in head section. I can't find solution. This is some parts from my code as it's really not necessary to paste everything as all working well, it's just some image issue. Of course as post url I'm using /links to share instead of /feed to post. As I believe, this is the only way to create ability to share this post by other people on Facebook. When posting as /feed, no one can share this post. $configuration['facebook_scope']=>'publish_stream,offline_access,read_stream,manage_pages'; $post_url = '/'.$Field['FacebookPageID'].'/links'; //post as /links for share $facebook = new Facebook($configuration['facebook_app']); //the Posting Parameters $PostData = array( 'message' => $Field['FacebookMessage'], 'link' => $Field['FacebookLink'], 'picture' => $Field['FacebookPicture'], //I'm not sure it's used for share, I think: it's not 'access_token' =>$OurAccessToken, ); $result = $facebook->api($post_url, 'post', $PostData); Please help me as I'm so close to make it real and I hope this post will help other people in future. P.S. I've checked url I want to share on https://developers.facebook.com/tools/debug and there everything looks fine with og:image
  14. Just use your imagination: have you returned anything from emailswitch() function?
  15. Yeah, it will return only Notice in that particular situation but I'm not bother with that, in production state it's safe to hide error_reporting at all. For sure my example works properly, and your is more elegant.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.